Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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
Ios 解析转发配置文件图像_Ios_Objective C_Json_Parsing_Uitableview - Fatal编程技术网

Ios 解析转发配置文件图像

Ios 解析转发配置文件图像,ios,objective-c,json,parsing,uitableview,Ios,Objective C,Json,Parsing,Uitableview,我正在开发一个显示Twitter用户时间线的应用程序。UITableView包含带有tweet、time和profile图标的单元格。但是,转发仍然有用户的个人资料图像,而不是原始海报的图像。JSON文件添加了一个名为retweeted_status的新键,该键有一个名为user的键,其中包含概要文件图像URL内容。如何生成条件语句以确定是否存在该转发的\u状态。如果没有,则获取图像,如下代码所示: static NSString *CellIdentifier = @"Cell"; UI

我正在开发一个显示Twitter用户时间线的应用程序。
UITableView
包含带有tweet、time和profile图标的单元格。但是,转发仍然有用户的个人资料图像,而不是原始海报的图像。JSON文件添加了一个名为
retweeted_status
的新键,该键有一个名为
user
的键,其中包含概要文件图像URL内容。如何生成条件语句以确定是否存在该
转发的\u状态。如果没有,则获取图像,如下代码所示:

 static NSString *CellIdentifier = @"Cell";

 UITableViewCell *cell = [self.tweetTableView
 dequeueReusableCellWithIdentifier:CellIdentifier];

 if (cell == nil) {
 cell = [[UITableViewCell alloc]
 initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
 }

dispatch_queue_t downloadQueue = dispatch_queue_create("image downloader", NULL);
dispatch_async(downloadQueue, ^{
    NSDictionary *tweet =_dataSource[[indexPath row]];
    NSDictionary *tweetSubtitle = _dataSource[[indexPath row]];

    //NSURL *retweetURL = [NSURL URLWithSting: [[tweet objectForKey:@"retweeted_status"] objectForKey:@"user"] objectForKey:@"profile_image_url"];


    NSURL *imageURL = [NSURL URLWithString:[[tweet  objectForKey:@"user"]objectForKey:@"profile_image_url"]];
    NSData *imageData = [NSData dataWithContentsOfURL:imageURL];

    //Need conditional function to find if retweet

    //NSLog(@"%@",imageData);
    dispatch_async(dispatch_get_main_queue(), ^{


        cell.textLabel.text = tweet[@"text"];
        cell.detailTextLabel.text = tweetSubtitle[@"created_at"];


        cell.imageView.image = [UIImage imageNamed:@"placeholder"];
        cell.imageView.image = [UIImage imageWithData:imageData];
    });
});
   //NSLog(@"screen name %@", tweetSubtitle[@"screen_name"]);

 return cell;
  }
如果我理解你-

if ([tweet objectForKey:@"retweeted_status"])
{
// the tweet has a retweeted status
}
else
{
// no retweeted status
}

我说得对吗?这就是你想要的?

是的,这就是我想要得到的。那么我写的代码有什么问题呢?我是说,这是检查元素是否存在的方法。。。