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 coordinates
array. , 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
Post a Comment