2011年7月7日星期四

Adding nil object to NSDictionary

NSDictionary and NSArray do not allow adding nil object to them.
But [NSNull null] can solve this problem in case you really want to have a "Null Object"


if(anObject!=nil)
{
[self setObject:anObject forKey:aKey];
return YES;
}
else
{
[self setObject:[NSNull null] forKey:aKey];
return NO;
}


reference: https://gist.github.com/307568

沒有留言:

發佈留言