Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3 changes for getBytes method

Tags:

ios

xcode8

swift3

I have tried to run the below code in swift 3

 var values = [UInt8](count:data!.length, repeatedValue:0)
 data!.getBytes(&values, length:data!.length)

where data is 'Data' datatype (NSData is change to 'Data' as per swift 3 guidelines)

I am not able to run the above code in Swift 3. Compiler gives error that "Argument Repeated value must precede argument". The same line of code was working in Swift 2.2

What will be the solution ?

like image 839
iDev Avatar asked Jun 29 '16 11:06

iDev


1 Answers

For Swift3 just use following:

let array = [UInt8](yourDataObject)

That's all, folks!)

like image 129
sVd Avatar answered Oct 21 '22 04:10

sVd