代碼很容易理解,但輸出不是。從KVC返回的類無效 - 對bool值感到困惑
屏幕xcdatamodel編輯:
類型的deleted
是String
。
@interface Row : NSManagedObject
(...)
@property (nonatomic, retain) NSString * deleted;
@end
@implementation Row
(...)
@dynamic deleted;
@end
別的地方代碼:
Row *row = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSString* fixedTypeDeletedClassString = NSStringFromClass([row.deleted class]);
NSString* KVCDeletedClassString = NSStringFromClass([[row valueForKeyPath:@"deleted"] class]);
NSLog(@"%@ is %@", row.deleted, fixedTypeDeletedClassString);
NSLog(@"%@ is %@", [row valueForKeyPath:@"deleted"], KVCDeletedClassString);
輸出是:
2014-05-07 17:29:26.170 iOSplayground[20814:90b] false is __NSCFString
2014-05-07 17:29:26.171 iOSplayground[20814:90b] 0 is __NSCFNumber
爲什麼類的屬性是不同的?
類是不同的,但至少看起來像正常澆注成型,但有一個更糟糕的情況:
2014-05-07 17:29:26.172 iOSplayground[20814:90b] true is __NSCFString
2014-05-07 17:29:26.172 iOSplayground[20814:90b] 0 is __NSCFNumber
我已經沒有行級快速原型製作的第一,並與KVC使用NSManagedObject
,和我在調試爲什麼有一個我沒有使用過的類的屬性方面花了很多時間。