NSNull handling for NSManagedObject properties values
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm setting values for properties of my NSManagedObject , these values are coming from a NSDictionary properly serialized from a JSON file. My problem is, that, when some value is [NSNull null] , I can't assign directly to the property: fight.winnerID = [dict objectForKey:@"winner"]; this throws a NSInvalidArgumentException "winnerID"; desired type = NSString; given type = NSNull; value = <null>; I could easily check the value for [NSNull null] and assign nil instead: fight.winnerID = [dict objectForKey:@"winner"] == [NSNull null] ? nil :