我是 iOS 初学者,在编码方面遇到了一些麻烦。通过发送 ASIHTTPRequest:
NSURL *url = [NSURL URLWithString:@"http://search.twitter.com/search.json?geocode=37.781157,-122.398720,25km"];
我收到这样的数据:
{
"created_at" = "Fri, 25 Jan 2013 17:48:29 +0000";
"from_user" = "ZacHWallS_SBI";
"from_user_id" = 252712138;
"from_user_id_str" = 252712138;
"from_user_name" = "ZACH WALLS";
geo = "<null>";
id = 294864332490162176;
"id_str" = 294864332490162176;
"in_reply_to_status_id" = 294861687004225537;
"in_reply_to_status_id_str" = 294861687004225537;
"iso_language_code" = en;
location = "BAY AREA CALIFORNIA";
metadata = {
"result_type" = recent;
};
"profile_image_url" = "http://a0.twimg.com/profile_images/3029389178/e3567459d147bc5d0a10f3c797b477aa_normal.png";
"profile_image_url_https" = "https://si0.twimg.com/profile_images/3029389178/e3567459d147bc5d0a10f3c797b477aa_normal.png";
source = "<a href="http://twitter.com/#!/download/ipad">Twitter for iPad</a>";
text = "@LilTioSBi yee ima slide through prolly";
"to_user" = LilTioSBi;
"to_user_id" = 35629694;
"to_user_id_str" = 35629694;
"to_user_name" = "Nevin Tio";
},
接下来我这样做:
-(void) requestFinished: (ASIHTTPRequest *) request {
NSString *theJSON = [request responseString];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSMutableArray *jsonDictionary = [parser objectWithString:theJSON];
//NSLog(@"\n\n%@", jsonDictionary);
NSMutableArray *userName = [userinfo objectForKey:@"from_user"];
NSLog(@"\n\n\n%@",userName);
我需要捕获“from_user”。然后运行,编译器说: [__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x755bbc0... 如何正确执行?