分配后获取null NSString

时间:2014-11-29 03:19:40

标签: objective-c

我有一个包含键/值对的NSMutableDictionary,当我尝试调试内容时,它似乎正确加载了:

NSLog(@"%@",[item objectForKey:@"title"]);//result: iOS in 24 hours.

但是当我尝试将此值分配给另一个NSString时,我得到一个空值

NSString *title = [item objectForKey:@"title"];// even tried to cast it using (NSString*)
NSLog(@"%@",title);//null value

1 个答案:

答案 0 :(得分:0)

如下所示: -

if (item[@"title"] == [NSNull null])
{
//your code
}