iOS Conversion de NSData en d'autres types


Exemple

À ficeler

Rapide

let string = String(NSString(data: data, encoding: NSUTF8StringEncoding)) //assuming data is a valid NSData object

Objectif c

NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; //assuming data is a valid NSData object
[string release];

Se ranger

Rapide

let array = data.bytes as! NSMutableArray //assuming data is a valid NSData object

Objectif c

NSMutableArray *array = (NSMutableArray *)[data bytes]; //assuming data is a valid NSData object

À Bytes Array

Rapide

let bytesArray = data.bytes as! UInt8 //assuming data is a valid NSData object

Objectif c

UInt8 *bytesArray = (UInt8 *)data.bytes; //assuming data is a valid NSData object