ios - how to alter NSMutableArray in an specific array -
i have nsmutablearray wich holds custom class of mkmapkit.
mappoint *placeobject = [[mappoint alloc] initwithtitle:title subtitle:subtitle coordinate:loc description:description storeimage:storeimage]; [annotationarray addobject:placeobject];
my routine fills placeobject
without image because load asynchronously , finished after couple of seconds. questions is: there way alter placeobject
within annotationarray
?
edit
to display issue in better way here code parts:
if (annotationarray == nil) { [self setannotationarray:[[nsmutablearray alloc] init]]; } (nsdictionary *locationdetails in parser.items) { __block nsdata *storeimagedata; dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_high, 0); dispatch_async(queue, ^{ storeimagedata = [nsdata datawithcontentsofurl:storeimageurl]; dispatch_sync(dispatch_get_main_queue(), ^{ uiimage *storeimagetmp = [uiimage imagewithdata:storeimagedata]; counterblock ++; nslog(@"async: %d", counterblock); [imagearray addobject:storeimagetmp]; }); }); mappoint *placeobject = [[mappoint alloc] initwithtitle:title subtitle:subtitle coordinate:loc description:description storeimage:storeimage]; [annotationarray addobject:placeobject]; } [mapview addannotations:annotationarray];
after done: dispatch_queue_t
start working. check every 2 seconds if loaded. start alter annotationarray , refresh annotations (remove -> add map witch additional image)
- (void) checkmap { if (counterblock == 547) { (int i=0; i<=counterblock; i++) { mappoint *point = annotationarray[i]; point.storeimage = imagearray[i]; } if(timer) { [timer invalidate]; timer = nil; } [mapview removeannotations:mapview.annotations]; [mapview addannotations:annotationarray]; } }
all need reference 1 of mappoint
objects in array. can set properties and/or call methods on object needed.
mappoint *point = annotationarray[x]; // x whatever index need point.image = ... // image
Comments
Post a Comment