Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 解析twitterjson_Iphone_Xcode - Fatal编程技术网

Iphone 解析twitterjson

Iphone 解析twitterjson,iphone,xcode,Iphone,Xcode,我编写了一些代码从Twitter搜索中获取数据,并将其放入UITableView,但我得到一个语法错误,指出No visible@interface for'NSArray'声明选择器'objectForKey: 下面是我用来获取JSON数据的代码: -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSDictionary *allDataDictionary = [NSJSONSerializatio

我编写了一些代码从Twitter搜索中获取数据,并将其放入
UITableView
,但我得到一个语法错误,指出
No visible@interface for'NSArray'声明选择器'objectForKey:

下面是我用来获取
JSON
数据的代码:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];

    NSArray *feed = [allDataDictionary objectForKey:@"results"];

    NSString *text = [feed objectForKey:@"text"];

    [array addObject:text];

    [[self myTableView] reloadData];    
}
(按左上角的“查看器”)


有什么帮助吗?谢谢:)

这是因为您正在拨打:

    NSString *text = [feed objectForKey:@"text"];
仔细观察:

[feed objectForKey:@"text"];
对象
feed
是一个
NSArray

    NSArray *feed = [allDataDictionary objectForKey:@"results"];
显然,
NSArray
没有方法
objectForKey:
,这是一本字典

因此,您可能对Objective-C有输入错误、混淆或误解。

NSDictionary*allDataDictionary=[NSJSONSerialization JSONObjectWithData:webData选项:0错误:无];
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];

NSArray *feed = [allDataDictionary objectForKey:@"results"];

for (NSDictionary *item in feed) {
    NSString *text = [item objectForKey:@"text"];
    [array addObject:text]; <- I assume this is NSMutableArray
}

[[self myTableView]reloadData];
NSArray*feed=[allDataDictionary objectForKey:@“结果”]; for(源中的NSDictionary*项){ NSString*text=[item objectForKey:@“text]”;
[array addObject:text];出现语法错误。NSArray没有“objectForKey”方法。