nspredicate - Need to write a predicate to search for a date in a core data object's array property (in my case array of dates) -


i need fetch object using core data. object has property datesarray(array of nsdate objects stored nsdata) use store array of dates. need check if array contains todays date , use object.

nsfetchrequest * request = [nsfetchrequest fetchrequestwithentityname:@"myentity"]; nserror * error; nsarray * fetchedarray = [context executefetchrequest:request error:&error]; nspredicate * predicate = [nspredicate predicatewithformat:@"entity.datesarray contains  %@",[nsdate date]]; (myentity * entity in fetchedarray) {     nsmutablearray *array = [nskeyedunarchiver unarchiveobjectwithdata:entity.datesarray];     [array filterusingpredicate:predicate];     if (array.count >0) {         [_mymutablearray addobject:entity];     } } 

you should not storing dates this. losing value of using core data. if have array of should on other side of relationship can retrieve efficiently underlying persistent store.

i suspect predicate lacks precision date object down nanosecond. if looking match "today" need work on less precision. perhaps string in specific format or store number , search within range (less x , greater y type of search).

again, storing actual dates in managed objects makes question easier still going dealing precision problem.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -