nsdictionary

Accessing JSON data inside an NSDictionary generated from NSJSONSerialization

烂漫一生 提交于 2019-12-08 03:38:14
问题 Having some trouble accessing the JSON data in the following URL ( http://jamesstenson.com/portraits/?json=1 ), basically I want to access the "full" "url"'s underneath "attachments". My code at the moment is as follows: NSError *e = nil; NSData *jsonFeed = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://jamesstenson.com/portraits/?json=1"]]; NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:jsonFeed options:NSJSONReadingMutableContainers error: &e]; if (!jsonData)

How to save (and retrieve) NSAttributedString in a NSDictionary

岁酱吖の 提交于 2019-12-08 02:52:13
问题 I am trying to save and retrieve XML data to a file. For this purpose I am using NSDictionary 's writeToFile: The question is, how to write and retrieve an attributed string to and from a file on disk using NSDictionary 's writeToFile: ? 回答1: NSAttributedString is not a property list object, so writeToFile: won't work. It does, however, conform to NSCoding , so you can write it to an archive with your dictionary as the root object (assuming that all the other objects in the dictionary also

Sort NSArray of NSDictionaries using comparator

偶尔善良 提交于 2019-12-07 23:12:13
问题 I've been trying to sort an NSArray of NSDictionaries using a comparator, but I cannot seem to get the output I desire. The output I'm trying to achieve is that A-Z usernames should come first in the sorted array, then usernames that start with a digit should come second in the sorted array, and lastly usernames that start with an underscore should be last in the sorted array. Any help is truly appreciated! EDIT: It should be sorted so it looks consistent through the whole NSArray so that:

SBJSON parsing NSString to NSDictionary

こ雲淡風輕ζ 提交于 2019-12-07 22:17:22
问题 I'm trying to parse an NSString that contains JSON data into an NSDictionary using SBJson 3.0.4, but when I do it, I get this error: "WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: -[__NSCFString JSONValue]: unrecognized selector sent to instance 0x6ab7a40" As far as I know (which isn't very far), the JSON I'm getting is valid, so I don't know why this is happening. My code compiles fine too… Here it is: NSString *tempURL =

How to display image from a RSS feed

白昼怎懂夜的黑 提交于 2019-12-07 20:38:21
问题 I'm trying to build an app that shows the latest RSS feeds from http://news.yahoo.com/rss/ I'm able to parse the xml using NSXMLParserDelegate, I'm able to show the date and time along with the title for the particular feed, but I also want to display an image for every feed, I know how to parse the main elements but I dont know how to pass the attributes for a child element which has a url as its key... e.g. the above feed consists of the following: <item> <title>fooo</title> <description

how to edit a plist programmatically in xcode 5 iOS 7?

耗尽温柔 提交于 2019-12-07 18:52:11
问题 how can I edit or change a value string from: in this plist I need change or Set "NO" in Enabled Value from Item 2, I see a lot examples, but not working, or are deprecated, or don't use ARC, any idea or example code? please help guys EDIT#1: I try this (not work) NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; path = [path stringByAppendingPathComponent:@"List.plist"]; NSFileManager *fileManager = [NSFileManager defaultManager];

Ios NSDictionary array - grouping values and keys

久未见 提交于 2019-12-07 17:58:35
问题 I have the following result of NSDictionary of Array Bath = { Keynsham = ( "nsham companies" ); }; Bath = { "Midsomer Norton" = ( "Keynsham companies" ); }; Bath = { "Norton Radstock" = ( "Keynsham taxi companies" ); }; Birmingham = { "Acock's Green" = ( "Acock's Green taxi companies" ); }; Birmingham = { "Alcester Lane's End" = ( "Alcester Lane's End taxi companies" ); }; How can i combine the values and keys so that I end up with only one category as shown below; Bath = { "Norton Radstock"

Foundation框架

雨燕双飞 提交于 2019-12-07 17:54:46
什么是框架 众多功能\API的集合 Foundation框架的作用 Foundation框架是Mac\iOS中其他框架的基础 Foundation框架包含了很多开发中常用的数据类型: 结构体 枚举 类 如何使用Foundation框架 要想使用Foundation框架中的功能,包含它的主文件即可 #import <Foundation/Foundation.h> Foundation框架中的类 Foundation框架提供了非常多好用的类, 比如 NSString : 字符串 NSArray : 数组 NSDictionary : 字典 NSDate : 日期 NSData : 数据 NSNumber : 数字 Foundation框架中的类都是以NS为前缀(Next Step的缩写) 乔布斯于1976年创立苹果公司 乔布斯于1985年离开苹果公司, 创立NeXT公司, 开发了Next Step操作系统 在开发Next Step操作系统过程中产生了Foundation框架 1997年, 苹果公司收购NeXT公司, 乔布斯重返苹果公司(Mac系统就是基于Next Step系统) 2007年, 苹果公司发布了iOS系统(iOS系统基于Mac系统) 不小心修改了系统文件 有时候会在不经意之间修改了系统自带的头文件, 比如NSString.h, 这时会出现以下错误: 解决方案很简单,

Generate a complete list of key-value coding paths for nested NSDictionary's?

可紊 提交于 2019-12-07 13:04:54
问题 I have an NSDictionary that contains keys and values, and some values will also be NSDictionary s... to an arbitrary (but reasonable) level. I would like to get a list of all valid KVC paths, e.g. given: { "foo" = "bar", "qux" = { "taco" = "delicious", "burrito" = "also delicious", } } I would get: [ "foo", "qux", "qux.taco", "qux.burrito" ] Is there a simple way to do this that already exists? 回答1: You could recurse through allKeys . A key is a key path, obviously, and then if the value is

Is there an easy way of sorting a plist (array of dictionaries) by key value?

混江龙づ霸主 提交于 2019-12-07 12:41:51
问题 I need to reorder a plist (an array of dictonaries) by Key value. In this example content I'd like to order by the value for the key Name (Matt, Joe): <dict> <key>Name</key> <string>Matt</string> <key>Details</key> <string>Me</string> </dict> <dict> <key>Name</key> <string>Joe</string> <key>Details</key> <string>You</string> </dict> Is there an easy way? I don't want to do it in code each time the app is run, I just want to do it to the data file. Any ideas? Happy to use any tool to get this