I have an NSManagedObject subclass called File. The the File Class has an attribute called "deleted" which is a boolean in the xcdatamodel file and an NSNumber in File.h. When the value is set to 1 weird things happen. The accessor method file.deleted/[file deleted] both return 1. When I call [file valueForKey:@"deleted"] it returns 0. It is also 0 when I print it in the console as an entire object (ex. po file or using NSLog() ). Additionally, it will not filter using an NSPredicate "deleted=1" on "filteredArrayUsingPredicate" on an array of files where some are deleted. I'm wondering what I am doing to get such inconsitent behavior.
Asked
Active
Viewed 279 times
0
-
First, show shome code. Especially some lines where you log the output of the getter and of the valueForKey. – Hermann Klecker Apr 18 '14 at 14:26
-
1Second, there is an `isDeleted`getter already on NSManagedObject. There might be a chnce that you get confused with a `deleted` iVar of a superclass - although that should not happen. I'd try renaming it from `deleted` to somthing `appDeleted` or so. – Hermann Klecker Apr 18 '14 at 14:28
-
2possible duplicate of [Core Data boolean key value change not reflected in fetch](http://stackoverflow.com/questions/18107286/core-data-boolean-key-value-change-not-reflected-in-fetch) - And yes, calling the attribute "deleted" is the problem. – Martin R Apr 18 '14 at 14:29