swift NSData NSString

They are interchangeable, so there's really no reason not to use NSString and its constructors when you need to. This will work fine:

var datastring: String = NSString(data:data, encoding:NSUTF8StringEncoding)
There's no type mismatch error here because Swift recognises the return type of NSString's constructor as matching the specified String type of datastring. You can then use datastring just like any other Swift string, e.g.

var foo = datastring + "some other string"

你可能感兴趣的:(NSString)