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

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

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

java - Cannot secure connection using TLS -