Skip to content

Commit bfdf5f2

Browse files
committed
Don't rely on bridging for NSData
1 parent 9db5173 commit bfdf5f2

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Tests/Foundation/TestDimension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestDimension: XCTestCase {
1717
original.encode(with: archiver)
1818
archiver.finishEncoding()
1919

20-
let unarchiver = NSKeyedUnarchiver(forReadingWith: encodedData as Data)
20+
let unarchiver = NSKeyedUnarchiver(forReadingWith: Data(encodedData))
2121
let decoded = Dimension(coder: unarchiver)
2222

2323
XCTAssertNotNil(decoded)

Tests/Foundation/TestNSAttributedString.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class TestNSAttributedString : XCTestCase {
286286
archiver.encode(string, forKey: NSKeyedArchiveRootObjectKey)
287287
archiver.finishEncoding()
288288

289-
let unarchiver = NSKeyedUnarchiver(forReadingWith: data as Data)
289+
let unarchiver = NSKeyedUnarchiver(forReadingWith: Data(data))
290290
unarchiver.requiresSecureCoding = true
291291
let unarchived = unarchiver.decodeObject(of: NSAttributedString.self, forKey: NSKeyedArchiveRootObjectKey)
292292

@@ -621,7 +621,7 @@ class TestNSMutableAttributedString : XCTestCase {
621621
archiver.encode(string, forKey: NSKeyedArchiveRootObjectKey)
622622
archiver.finishEncoding()
623623

624-
let unarchiver = NSKeyedUnarchiver(forReadingWith: data as Data)
624+
let unarchiver = NSKeyedUnarchiver(forReadingWith: Data(data))
625625
unarchiver.requiresSecureCoding = true
626626
let unarchived = unarchiver.decodeObject(of: NSMutableAttributedString.self, forKey: NSKeyedArchiveRootObjectKey)
627627

Tests/Foundation/TestNSString.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,31 +1199,31 @@ class TestNSString: LoopbackServerTest {
11991199
do {
12001200
let string = NSString(string: "this is an external string that should be representable by data")
12011201

1202-
let UTF8Data = try XCTUnwrap(string.data(using: String.Encoding.utf8.rawValue, allowLossyConversion: false)) as NSData
1203-
let UTF8Length = UTF8Data.length
1202+
let UTF8Data = try XCTUnwrap(string.data(using: String.Encoding.utf8.rawValue, allowLossyConversion: false))/* as NSData*/
1203+
let UTF8Length = UTF8Data.count
12041204
XCTAssertEqual(UTF8Length, 63, "NSString should successfully produce an external UTF8 representation with a length of 63 but got \(UTF8Length) bytes")
12051205

1206-
let UTF16Data = try XCTUnwrap(string.data(using: String.Encoding.utf16.rawValue, allowLossyConversion: false)) as NSData
1207-
let UTF16Length = UTF16Data.length
1206+
let UTF16Data = try XCTUnwrap(string.data(using: String.Encoding.utf16.rawValue, allowLossyConversion: false))/* as NSData*/
1207+
let UTF16Length = UTF16Data.count
12081208
XCTAssertEqual(UTF16Length, 128, "NSString should successfully produce an external UTF16 representation with a length of 128 but got \(UTF16Length) bytes")
12091209

1210-
let ISOLatin1Data = try XCTUnwrap(string.data(using: String.Encoding.isoLatin1.rawValue, allowLossyConversion: false)) as NSData
1211-
let ISOLatin1Length = ISOLatin1Data.length
1210+
let ISOLatin1Data = try XCTUnwrap(string.data(using: String.Encoding.isoLatin1.rawValue, allowLossyConversion: false))/* as NSData*/
1211+
let ISOLatin1Length = ISOLatin1Data.count
12121212
XCTAssertEqual(ISOLatin1Length, 63, "NSString should successfully produce an external ISOLatin1 representation with a length of 63 but got \(ISOLatin1Length) bytes")
12131213
}
12141214

12151215
do {
12161216
let string = NSString(string: "🐢 encoding all the way down. 🐢🐢🐢")
12171217

1218-
let UTF8Data = try XCTUnwrap(string.data(using: String.Encoding.utf8.rawValue, allowLossyConversion: false)) as NSData
1219-
let UTF8Length = UTF8Data.length
1218+
let UTF8Data = try XCTUnwrap(string.data(using: String.Encoding.utf8.rawValue, allowLossyConversion: false))/* as NSData*/
1219+
let UTF8Length = UTF8Data.count
12201220
XCTAssertEqual(UTF8Length, 44, "NSString should successfully produce an external UTF8 representation with a length of 44 but got \(UTF8Length) bytes")
12211221

1222-
let UTF16Data = try XCTUnwrap(string.data(using: String.Encoding.utf16.rawValue, allowLossyConversion: false)) as NSData
1223-
let UTF16Length = UTF16Data.length
1222+
let UTF16Data = try XCTUnwrap(string.data(using: String.Encoding.utf16.rawValue, allowLossyConversion: false))/* as NSData*/
1223+
let UTF16Length = UTF16Data.count
12241224
XCTAssertEqual(UTF16Length, 74, "NSString should successfully produce an external UTF16 representation with a length of 74 but got \(UTF16Length) bytes")
12251225

1226-
let ISOLatin1Data = string.data(using: String.Encoding.isoLatin1.rawValue, allowLossyConversion: false) as NSData?
1226+
let ISOLatin1Data = string.data(using: String.Encoding.isoLatin1.rawValue, allowLossyConversion: false)/* as NSData?*/
12271227
XCTAssertNil(ISOLatin1Data)
12281228
}
12291229
}

Tests/Foundation/TestSocketPort.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class TestSocketPort : XCTestCase {
8484

8585
let received = expectation(description: "Message received")
8686
let delegate = TestPortDelegateWithBlock { message in
87-
XCTAssertEqual(message.components as? [AnyHashable], [data as NSData])
87+
XCTAssertEqual(message.components as? [AnyHashable], [data._bridgeToObjectiveC()])
8888
received.fulfill()
8989
}
9090

0 commit comments

Comments
 (0)