ios - Coredata working with data (Multithreading) -


i need place hotspots map. of them saved coredata (it's 25000). need 25000 annotations. implement mkannotation protocol hotspot entity.

selected solution situation multithreading. after pins on map of them has no data (data ).

here code populate data in array

- (void)addannotationsforcurrentlocation {     nsinteger hotspotscount = [hotspot mr_countofentities];     self.testspotsarray = [[nsmutablearray alloc] initwithcapacity:hotspotscount];     nsinteger lastthread;     nsinteger threads = 5;     //calculate how spots in      nsinteger spotsinthread = hotspotscount/threads;     //calclulate how mush threads in 1 spot     lastthread = hotspotscount - spotsinthread*(threads-1);     dispatch_queue_t firstthreadqueue = dispatch_queue_create("com.thecloud.firstthreadqueue", dispatch_queue_concurrent);     dispatch_queue_t secondthreadqueue = dispatch_queue_create("com.thecloud.secondthreadqueue", dispatch_queue_concurrent);     dispatch_queue_t thirdthreadqueue = dispatch_queue_create("com.thecloud.thirdthreadqueue", dispatch_queue_concurrent);     dispatch_queue_t forththreadqueue = dispatch_queue_create("com.thecloud.forththreadqueue", dispatch_queue_concurrent);     dispatch_queue_t fifththreadqueue = dispatch_queue_create("com.thecloud.fifththreadqueue", dispatch_queue_concurrent);      dispatch_group_t fillarraygroup = dispatch_group_create();     nslock *arraylock = [[nslock alloc] init];      dispatch_group_async(fillarraygroup, firstthreadqueue, ^{         [self fetchwithoffest:0 andlimit:spotsinthread andlock:arraylock];         ddloginfo(@"com.thecloud.firstthreadqueue , self.testspotsarray objects - %i", [self.testspotsarray count]);     });      //other queue      dispatch_group_notify(fillarraygroup, dispatch_get_main_queue(), ^{         [self.treecontroller setannotations:self.testspotsarray];     });      dispatch_release(fillarraygroup); } - (void)fetchwithoffest:(nsinteger)offset andlimit:(nsinteger)limit andlock:(nslock *)arraylock {     nsfetchrequest *request = [hotspot mr_requestall];     [request setfetchoffset:offset];     [request setfetchlimit:limit];     [request setreturnsobjectsasfaults:no];     nsarray *array = [hotspot mr_executefetchrequest:request];     (int i=0; < [array count]; i++) {         hotspot *spot = (hotspot *)[array objectatindex:i];         [spot convertlogitudeandlattitudetolocationcoordinate];         [arraylock lock];         [self.testspotsarray addobject:spot];         [arraylock unlock];     } } 

after when tap on of pins no popup description appears. solution have full data in each object in array of annotations?

upd

problem solved. did change in entity model. when add entity annotations array instead of

-(nsstring *)title {     return self.title; }  -(nsstring *)subtitle {     return self.spottoaddress.addressline1; }  -(cllocationcoordinate2d) coordinate {     return cllocationcoordinate2dmake([self.latitude doublevalue], [self.longitude doublevalue]); } 

i use direct assignment

- (void)prepareannotation {     _title = self.name;     _subtitle = self.spottoaddress.addressline1;     _coordinate = cllocationcoordinate2dmake([self.latitude doublevalue], [self.longitude doublevalue]); } 

problem solved. did change in entity model. when add entity annotations array instead of

-(nsstring *)title {     return self.title; }  -(nsstring *)subtitle {     return self.spottoaddress.addressline1; }  -(cllocationcoordinate2d) coordinate {     return cllocationcoordinate2dmake([self.latitude doublevalue], [self.longitude doublevalue]); } 

i use direct assignment

- (void)prepareannotation {     _title = self.name;     _subtitle = self.spottoaddress.addressline1;     _coordinate = cllocationcoordinate2dmake([self.latitude doublevalue], [self.longitude doublevalue]); } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -