ios - Core Data and unix timestamp date -


i have core data user locations: longitude,latitude etc.

and try list of available days:

nsmanagedobjectcontext *context = [self managedobjectcontext];   nsfetchrequest * request = [[nsfetchrequest alloc]init]; [request setentity:[nsentitydescription entityforname:@"locations" inmanagedobjectcontext:context]];  nspredicate *predicate = [nspredicate predicatewithformat:@"device_id == %@", deviceid]; [request setpredicate:predicate];  nssortdescriptor *sortdescriptor = [nssortdescriptor sortdescriptorwithkey:@"created_at" ascending:no]; [request setsortdescriptors:[nsarray arraywithobject:sortdescriptor]];  request.returnsdistinctresults = yes;  [request setpropertiestofetch:@[@"created_at"]];  [request setresulttype:nsdictionaryresulttype];  nsarray *results = [context executefetchrequest:request error:null];   nsmutablearray *datearray = [[nsmutablearray alloc]init];  nsdateformatter *formatter= [[nsdateformatter alloc] init];  for(nsdictionary* obj in results ) {       nsdate *date = [nsdate datewithtimeintervalsince1970:[[obj valueforkey:@"created_at"] integervalue]];      [formatter setlocale:[nslocale currentlocale]];     [formatter setdateformat:@"dd-mm-yyyy"];     nsstring *datestring = [formatter stringfromdate:date];      if (datearray.count == 0) {         [datearray addobject:datestring];     }     else{         if (![datearray containsobject:datestring]) {             [datearray addobject:datestring];         }     }   } nslog(@"object: %@", datearray); 

everything works fine when have many position in core data take while... ideas how can modified coredata request make faster ?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -