mardi 26 août 2014

Swift language: How to call SecRandomCopyBytes


Vote count:

0




From Objective-C, I could do this:



NSMutableData *data = [NSMutableData dataWithLength:length];
int result = SecRandomCopyBytes(kSecRandomDefault, length, data.mutableBytes);


When attempting this in Swift, I have the following:



let data = NSMutableData(length: Int(length))
let result = SecRandomCopyBytes(kSecRandomDefault, length, data.mutableBytes)


but I get this compiler error:



'Void' is not identical to 'UInt8'


The data.mutableBytes parameter is rejected because the types not match, but I can't figure out how to coerce the parameter (and I'm presuming it's somehow safe to do).



asked 1 min ago

Daniel

1,308






Swift language: How to call SecRandomCopyBytes

Aucun commentaire:

Enregistrer un commentaire