NSMutableArray of ClLocationCoordinate2D

前端 未结 5 959
遇见更好的自我
遇见更好的自我 2020-12-16 11:27

I\'m trying to create then retrieve an array of CLLocationCoordinate2D objects, but for some reason the array is always empty.

I have:

NSMutableArray         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 12:27

    To stay in object land, you could create instances of CLLocation and add those to the mutable array.

    CLLocation *towerLocation = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
    [currentDisplayedTowers addObject:towerLocation];
    

    To get the CLLocationCoordinate struct back from CLLocation, call coordinate on the object.

    CLLocationCoordinate2D coord = [[currentDisplayedTowers lastObject] coordinate];
    

提交回复
热议问题