Getting Bad Access error with iOS Annotations and Arrays -


the code below conducting search mklocalsearch , loading results array.

this array gets passed [self.mapview addannotations:annotations] method. works great until try dismiss viewcontroller tapping button (in navigation bar storyboards).

i exc_bad_access(code=1, address=0x4). if comment out show pins section below problem goes away (but of course not loading annotations).

please help!

-(void)issuelocalsearchlookup:(nsstring *)searchstring usingplacemarksarray:(nsarray *)placemarks {   self.coords =  mapview.userlocation.coordinate;   // set size of region want search results for. mkcoordinatespan span = mkcoordinatespanmake(0.001250, 0.001250); mkcoordinateregion region = mkcoordinateregionmake(mapview.userlocation.coordinate, span);     [self.mapview setregion:region animated:yes];    // create search request self.localsearchrequest = [[mklocalsearchrequest alloc] init]; self.localsearchrequest.region = region; self.localsearchrequest.naturallanguagequery = searchstring;  // perform search request... self.localsearch = [[mklocalsearch alloc] initwithrequest:self.localsearchrequest]; [self.localsearch startwithcompletionhandler:^(mklocalsearchresponse *response, nserror *error) {      if(error){          nslog(@"localsearch startwithcompletionhandlerfailed!  error: %@", error);         return;      } else {          // here because have data!          for(mkmapitem *mapitem in response.mapitems){              // show pins...              nsmutablearray *annotations = [nsmutablearray array];               annotation *annotation = [[annotation alloc] initwithcoordinate: mapitem.placemark.location.coordinate];             annotation.title = mapitem.name;             annotation.subtitle = mapitem.placemark.addressdictionary[(nsstring *)kabpersonaddressstreetkey];             [mapview addannotation:annotation];             nslog(@"name result: = %@", mapitem.name);                [self.mapview addannotations:annotations];                  nslog(@"name result: = %@", mapitem.name);           }          mkcoordinatespan span = mkcoordinatespanmake(0.01, 0.01);         mkcoordinateregion region = mkcoordinateregionmake(self.coords, span);         [self.mapview setregion:region animated:yes];       } }];            }   

i had set custom annotation subclass of nkplacemark....i needed have subclass of nsobject.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -