Skip to content

Commit 25092bd

Browse files
authored
Merge pull request #721 from e78l/plist-any
2 parents 086c4ad + e6859cd commit 25092bd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Foundation/NSPropertyList.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ open class PropertyListSerialization : NSObject {
4444
#else
4545
let fmt = CFPropertyListFormat(format.rawValue)
4646
#endif
47-
return CFPropertyListIsValid(unsafeBitCast(_SwiftValue.store(plist), to: CFPropertyList.self), fmt)
47+
let plistObj = _SwiftValue.store(plist)
48+
return CFPropertyListIsValid(plistObj, fmt)
4849
}
49-
50-
open class func data(fromPropertyList plist: AnyObject, format: PropertyListFormat, options opt: WriteOptions) throws -> Data {
50+
51+
open class func data(fromPropertyList plist: Any, format: PropertyListFormat, options opt: WriteOptions) throws -> Data {
5152
var error: Unmanaged<CFError>? = nil
5253
let result = withUnsafeMutablePointer(to: &error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> CFData? in
5354
#if os(OSX) || os(iOS)
@@ -56,15 +57,16 @@ open class PropertyListSerialization : NSObject {
5657
let fmt = CFPropertyListFormat(format.rawValue)
5758
#endif
5859
let options = CFOptionFlags(opt)
59-
return CFPropertyListCreateData(kCFAllocatorSystemDefault, plist, fmt, options, outErr)
60+
let plistObj = _SwiftValue.store(plist)
61+
return CFPropertyListCreateData(kCFAllocatorSystemDefault, plistObj, fmt, options, outErr)
6062
}
6163
if let res = result {
6264
return res._swiftObject
6365
} else {
6466
throw error!.takeRetainedValue()._nsObject
6567
}
6668
}
67-
69+
6870
/// - Experiment: Note that the return type of this function is different than on Darwin Foundation (Any instead of AnyObject). This is likely to change once we have a more complete story for bridging in place.
6971
open class func propertyList(from data: Data, options opt: ReadOptions = [], format: UnsafeMutablePointer<PropertyListFormat>?) throws -> Any {
7072
var fmt = kCFPropertyListBinaryFormat_v1_0

0 commit comments

Comments
 (0)