If I create a new NSData object of a specific size using dataWithBytes:length:, what is the most efficient way to create the input bytes (20 Mb worth) of random characters, pref
You might consider using CCRandomGenerateBytes function from CommonCrypto to generate random data. Like:
func generateBytes(length : Int) throws -> NSData? {
var bytes = [UInt8](count: length, repeatedValue: UInt8(0))
let statusCode = CCRandomGenerateBytes(&bytes, bytes.count)
if statusCode != CCRNGStatus(kCCSuccess) {
return nil
}
return NSData(bytes: bytes, length: bytes.count)
}