friedbunny/TimeZoneCoordinate

Swift 3.x bridging to TimeZone does not work

Opened this issue · 2 comments

This category fails to bridge in Swift 3.x — neither NSTimeZone nor TimeZone receive this property.

Meanwhile, Swift 2.x bridges correctly to:

extension NSTimeZone {
    
    /** Coordinate for the largest populated place within the given time zone. */
    public var coordinate: CLLocationCoordinate2D { get }
}

/cc @1ec5

Casting to NSTimeZone in Swift 3 does work, though it’s a bit unfortunate:

let tz = TimeZone.current as NSTimeZone
let coordinate = tz.coordinate

print(tz.description, coordinate.latitude, coordinate.longitude)
// America/New_York (current) 40.714 -74.006
1ec5 commented

TimeZone is a Swift struct in Swift, so it isn't possible to extend it via an Objective-C category. TimeZone and NSTimeZone share most built-in methods and properties in common, but that's because the Swift standard library "overlays" TimeZone onto NSTimeZone, rather than the other way around.