I've been using stringWithUTF8String to convert my NSData to NSString as follows:
if ([[NSString stringWithUTF8String:[responsedata bytes]] isEqualToString:@"SUCCESS"]){
dostuff...
}
It's been working fine; however, since the 8.2 iOS update, [[NSString stringWithUTF8String:[responsedata bytes]]
returned nil.
I solved the problem by using the following code:
NSString *responseDataString = [[NSString alloc] initWithData:responsedata encoding:NSUTF8StringEncoding];
if ([responseDataString isEqualToString:@"SUCCESS"]){
dostuff...
}
In both cases responsedata
's printed description was the same: <OS_dispatch_data: data[0x7aeb6500] = { leaf, size = 7, buf = 0x7c390360 }>
My question is: WHY would the first option return nil, and WHY suddenly after the iOS 8.2 update?