objective c - Problems retrieving NSDate object from Core Data using KVC -


i have dates stored in core data nsdate objects. when try retrieve them using fetch request , -(id)valueforkey: integer instead of nsdate object.

nserror *error = nil; nsarray *results = [managedobjectcontext executefetchrequest:request error:&error];     nsmanagedobject *entity = [results lastobject]; nsdate *date = [entity valueforkey:@"updated"]; 

when use dot notation such myentity.updated nsdate object correctly not when use kvc method.

the reason want use -(id)valueforkey: because running code on every entity in core data , don't want define each entity explicitly. alternativly code bunch of if statements test iskindofclass, require lot of code , seems kind of hackish.

any suggestions appreciated.

you must not call managed object attribute "updated", conflicts isupdated method of nsmanagedobject.

similar problems occur if call , attribute "deleted", compare core data nspredicate "deleted == no" not work expected short analysis.

renaming attribute should solve problem. unfortunately, xcode not warn that.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -