Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data Supporting NSNull

Is it at all possible to get Core Data to allow assignment of NSNull? I'm using the JSONKit and it defaults to assigning NSNull. I'd prefer to be able to do my deserialization like this:

- (void)deserialize:(NSDictionary *)dictionary
{
  self.name = [dictionary objectForKey:@"name"];
} 

Instead of like this:

- (void)deserialize:(NSDictionary *)dictionary
{
   NSNull *null = [NSNull null];
   NSString *value = [dictionary objectForKey:@"name"];
   self.name = (value != null) ? value : nil;
}
like image 343
Kevin Sylvestre Avatar asked Dec 28 '22 19:12

Kevin Sylvestre


1 Answers

One thought would be to create a category for NSDictionary. The category could then contain this behavior.

like image 85
tjg184 Avatar answered Jan 11 '23 17:01

tjg184