我有两个Feed,我希望它们的内容填充表视图,但是当我想显示图像时,键是不同的,所以在cellForRowAtIndexPath中我有:
if ([[stories objectAtIndex:storyIndex] objectForKey:@"url"] ==nil) {
[cell.imag setImageWithURL:[NSURL URLWithString:[[stories objectAtIndex:storyIndex] objectForKey:@"_text"]] placeholderImage:[UIImage imageNamed:@"Alb.png"]];
}
else
[cell.imag setImageWithURL:[NSURL URLWithString:[[stories objectAtIndex:storyIndex] objectForKey:@"url"]] placeholderImage:[UIImage imageNamed:@"Alb.png"]];
但它不起作用。
答案 0 :(得分:1)
使用此代码
if ([dictionary objectForKey:key]) {
// contains object
}
else
{
//no object
}