mw99 / DataCompression

Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Apache License 2.0
287 stars 57 forks source link

Xcode deprecation warnings for withUnsafeBytes #24

Closed klauslanza closed 4 years ago

klauslanza commented 4 years ago

Is there any plan to fix the deprecations for

'withUnsafeBytes is deprecated: use withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R instead

or is there a reasoning behind?

Thanks for the great work

mw99 commented 4 years ago

Hi!

The fileprivate extension in line 436 should actually prevent that deprecation warning from appearing. I just tested with Xcode 11.3.1 and I don't see any warnings. Do you use any special warning compiler switches? Also tell me about your environment (e.g. Xcode version...).

klauslanza commented 4 years ago

Hi, you're right, sorry for the wrong issue! I was using this great lib with manual importing, and the fileprivate got lost in the move. I'm using Xcode Version 11.3.1, and now it's all fixed.

Apart from that, I suppose int the long run this could be moved to a non-deprecated one, for better use. Thanks

mw99 commented 4 years ago

Ah nice. Problems that solve themselves are the best.

Apart from that, I suppose int the long run this could be moved to a non-deprecated one, for better use.

Yes, I know what you mean. That was also my first intention when the warning appeared, but the new alternative (I think its called withUnsafeBufferBytes?) does force me to do a forced unwrapping. (Swift !). And the documentation never states when the Data type would result in a nil pointer there. That's all pretty messy. So for now we stay safe and use the deprecated methods.