我已经做了很多研究,并且我读了很多关于类似问题的内容,但是他们中没有一个实际上是像我这样的Bool类型,而且我已经在这几天解决了这个问题。
Xcode 5 iOS应用程序目标:6.1或7.1(错误保留) 我有一个coreData数据库,我刚刚添加了一个bool类型的新条目。
当我尝试将其设置为FALSE / TRUE时,我收到以下错误:
1)
// in <Record.m>
@dynamic poked;
// throws error: "Property implementation must have its declaration in interface
"Record""
The Entity in my CoreData DB is named Record and holds an Attribute named poked of type BOOL
2)
// in <Record.h>
@property (nonatomic, retain) BOOL *poked;
// throws error "Property with 'retain (or strong)' attribute must be of object type"
So now, I know it is because my DB entry is type bool, I can't use the retain attribute, but I've been breaking my head about it and can't find how to manipulate a BOOL DB entry on the web.
3)
// in iBAction for a button <mainViewController.m>
Record *newEntry = [NSEntityDescription insertNewObjectForEntityForName:@"Record" inManagedObjectContext:self.managedObjectContext];
newEntry.poked = TRUE;
// throws warning: "Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'int'"
任何想法,? 有人有一个如何访问CoreData DB中的bool条目的例子吗?
谢谢你们!
答案 0 :(得分:0)
使用核心数据时,除非允许使用基本类型,否则实际上是在处理对象。所以,你的财产“戳”实际上是@property NSNumber * poked;。
您可以使用@YES或@NO为其指定值。