For some reason the location
property on a PHAsset
is only exposed in Objective-c and not in Swift.
Documentation: PHAsset.location
To work around it, I figured I could create a Objective-C class whose sole purpose is to extract the location and import it into Swift.
LocationGetter.h
@interface LocationGetter : NSObject
+ (CLLocation *)locationForAsset:(PHAsset *) asset;
@end
LocationGetter.m
@implementation LocationGetter
+ (CLLocation *)locationForAsset:(PHAsset *) asset {
return [asset location];
}
@end
So far so good, but when I try to use it in Swift:
LocationGetter.locationForAsset(ass)
'LocationGetter.Type' does not have a member named 'locationForAsset'
Bonus question: Why on earth didn't Apple expose location
in swift?