ios - Converting CLLocationCoordinates2D into an NSValue -


i'm trying convert cllocationcoordinates nsvalue used in array brought later in app. here code:

  nsuinteger count = [self.locations count];     cllocationcoordinate2d coordinates[count];     (nsinteger = 0; < count; i++) {         coordinates[i] = [(cllocation *)self.locations[i] coordinate];         nsvalue *locationvalue = [nsvalue valuewithmkcoordinate:coordinates[i]];         [_locationsarray addobject:locationvalue];         nslog(@"location = %@", _locationsarray);     } 

however nslog displays array filled (null) values. i'm not sure have gone wrong here, point me in right direction?

i didn't see need in coordinatesarray. , didn't initialised it. try:

_locationsarray = [nsmutablearray array]; (cllocation *location in self.locations) {     nsvalue *locationvalue = [nsvalue valuewithmkcoordinate: location.coordinate];     [_locationsarray addobject:locationvalue];     nslog(@"location = %@", _locationsarray); } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -