0
我已经做了大量的研究,并且阅读了许多关于类似问题的内容,但是他们中没有一个实际上来自我的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中的布尔入口的例子吗?
谢谢你们!
帮助已经,谢谢。但是现在,我如何在if语句中使用数据库条目,例如,如果我想查看值是“TRUE”还是“FALSE”(或“YES”/“NO”)? – Studiologe
NSNumber有一个名为“boolValue”的方法。所以,你会像读取你的值(object.poked.boolValue) – J2theC