Skip to content
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

replaceWithChannel:channel:error method in ZZDataChannel.m fails in Swift 3 #148

Open
ilyakaz opened this issue Sep 26, 2016 · 1 comment

Comments

@ilyakaz
Copy link

ilyakaz commented Sep 26, 2016

ivar _allData is declared as NSData and is being cast to NSMutableData in this method in order to call setData on it. This operation fails at runtime in Swift 3 with the error: [Foundation._SwiftNSData setData:]: unrecognized selector sent to instance.

The solution appears to be to declare _allData as NSMutableData instead, which is what it should have probably been declared to begin with.

@pixelglow
Copy link
Owner

pixelglow commented Oct 5, 2016

I admit the internal ZZDataChannel API isn't ideal. It does double duty initialised with NSData or NSMutableData and so sometimes gets into an inconsistent state as you've noticed.

We should have a ZZDataChannel and a ZZMutableDataChannel instead -- the ZZDataChannel can then throw errors for inappropriate write operations. Then ZZArchive could be initialised with NSMutableData as an alternative, which leads to the creation of a ZZMutableDataChannel.

The write operations that should result in errors in the fixed ZZDataChannel are temporaryChannel:, replaceWithChannel:error:, removeAsTemporary and newOutput:.

Anyone interested in working on a fix? I'll leave this open for discussion for a week or two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants