Lan*_*nce 5 iphone xcode cocoa-touch objective-c
我正在使用这里找到的JSON框架:http://stig.github.com/json-framework在我的iPhone应用程序中.我正在尝试将一些数据解析为NSArray(顺序很重要,因此字典不起作用)
我从服务器获得了JSON字符串,这就是它的样子:
{"users":["example1@examle.com","example2@example.com","example3@example.com"]}
Run Code Online (Sandbox Code Playgroud)
我想最终得到的是NSArray,以便:
myArray[0] == "example1@example.com"
myArray[1] == "example2@example.com"
myArray[3] == "example3@example.com"
Run Code Online (Sandbox Code Playgroud)
这应该很简单,但对我而言,我能得到的最接近的是这个输出:
( "example1@example.com", "example2@example.com", "example3@example.com")
从这段代码
NSDictionary *dictionary = [jsonString JSONValue];
for(NSString *key in dictionary){
NSLog(@"Dictionary value for \"%@\" is \"%@\"",key, [dictionary objectForKey:key]);
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
Ale*_*yne 10
NSArray *myArray = [dictionary objectForKey:@"users"];
Run Code Online (Sandbox Code Playgroud)