-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix decoding NSData from an NSCoder #1447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decoding NSData from an NSCoder #1447
Conversation
@swift-ci please test |
TestFoundation/TestNSData.swift
Outdated
let data = NSData(bytes: bytes, length: bytes.count) | ||
|
||
let archiver = NSKeyedArchiver() | ||
let key = "data" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key
is never used.
TestFoundation/TestNSData.swift
Outdated
data.encode(with: archiver) | ||
let encodedData = archiver.encodedData | ||
|
||
let unarchiver = NSKeyedUnarchiver(forReadingWithData: encodedData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://developer.apple.com/documentation/foundation/nskeyedunarchiver/1410862-init the method is init(forReadingWith data: Data)
so needs a small adjustment.
5143e01
to
a7e594e
Compare
@swift-ci please test |
@spevans thanks for the comments. Fixed both. Botched rebase, apologies. |
@swift-ci please test |
@gmilos looks like this one didn't go in either. Needs a rebase now |
Is this relevant still? |
@swift-ci please test |
I’m closing this for now as no longer relevant. Please ping me if you feel this is done in error. |
@millenomi @gmilos is out this week but i think this patch is still relevant - if not the implementation the test case should still be merged |
Reopened. |
I just ran the test against |
Since `as? Data` now works from a NSData object (but requires an extra bridging call), keep the status quo.
@swift-ci please test and merge |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
The new test case shows how
NSData
decoding could fail. Fix included.