IPhone - Basic Data Bool Values?

I have a BOOL in my master data. I want the value to be null unless I set it to either YES or NO. Is it possible to do this? in my code, how can I check if a value is set yet or not?

In my nsmanagedObject I use NSNumber for my BOOL, in my base mdoel file I have BOOL.

+3
source share
3 answers

CoreData allows you to set default values. Bool may contain "YES", "NO", "None". Setting the default value to No makes the return value null, which is exactly what I need.

+5

Boolean , , NSNumber.

, NO, . false , .

, , , nil , , .

+2

- , "" "" "" , , . Core Data "" , . Core Data :

[myManagedObject setValue: nil forKey:@"attributeOfMyManagedObject"];

SQL , "NULL", .

0
source

Source: https://habr.com/ru/post/1775714/


All Articles