Created
March 29, 2021 14:06
-
-
Save spevans/c5aa3a23f1e86fece27f7a25ce818ff9 to your computer and use it in GitHub Desktop.
patch2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Sources/Foundation/NSTimeZone.swift b/Sources/Foundation/NSTimeZone.swift | |
index 8f710d62..67eeed3e 100644 | |
--- a/Sources/Foundation/NSTimeZone.swift | |
+++ b/Sources/Foundation/NSTimeZone.swift | |
@@ -95,10 +95,13 @@ open class NSTimeZone : NSObject, NSCopying, NSSecureCoding, NSCoding { | |
public convenience init?(abbreviation: String) { | |
let abbr = abbreviation._cfObject | |
- guard let name = unsafeBitCast(CFDictionaryGetValue(CFTimeZoneCopyAbbreviationDictionary(), unsafeBitCast(abbr, to: UnsafeRawPointer.self)), to: NSString?.self) else { | |
- return nil | |
+ let nsname = withExtendedLifetime(abbr) { _ -> NSString? in | |
+ return unsafeBitCast(CFDictionaryGetValue(CFTimeZoneCopyAbbreviationDictionary(), unsafeBitCast(abbr, to: UnsafeRawPointer.self)), to: NSString?.self) | |
+ } | |
+ if let name = nsname?._swiftObject { | |
+ self.init(name: name, data: nil) | |
} | |
- self.init(name: name._swiftObject , data: nil) | |
+ return nil | |
} | |
open func encode(with aCoder: NSCoder) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment