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