AudioStreamer icon indicating copy to clipboard operation
AudioStreamer copied to clipboard

Deprecated ''withUnsafeMutableBytes' and 'withUnsafeBytes'

Open FancyRobot opened this issue 6 years ago • 1 comments

Hi, Thank you for creating this framework, it has been exactly what I needed for my project. Since the shift to swift 5 there are two warnings due to deprecation:

''withUnsafeMutableBytes' is deprecated: use withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R instead

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

I have not focused on fixing this yet but I thought of mentioning it already.

FancyRobot avatar Dec 17 '19 07:12 FancyRobot

For those who are looking for the fix.

_ = data.withUnsafeBytes { pointer in 
    guard let bytes = pointer.baseAddress?.assumingMemoryBound(to: Unit8.self) else { return }
    //... use bytes here
} 

NeilsUltimateLab avatar Mar 22 '21 05:03 NeilsUltimateLab