首页 > 地图,怎样把CLLocationCoordinate2D转为CLLocation?

地图,怎样把CLLocationCoordinate2D转为CLLocation?

怎样把CLLocationCoordinate2D转为CLLocation?


写个Category呗:

//.h
#import <CoreLocation/CoreLocation.h>

@interface CLLocation (ConstructWithCoordinate)
+ (CLLocation *)constructWithCoordinate:(CLLocationCoordinate2D)coordinate;
@end


//.m
@implementation CLLocation (ConstructWithCoordinate)
+ (CLLocation *)constructWithCoordinate:(CLLocationCoordinate2D)coordinate {
    return [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude];
}
@end
【热门文章】
【热门文章】