[ObjectiveC]NSDATA, NSDICTIONARY, NSSTRING互轉

NSDATA-->NSDICTIONARY spa

NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];

NSDICTIONARY-->NSDATA code

NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];


NSDATA-->NSSTRING it

NSString *body = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];

NSSTRING-->NSDATA
io

NSData *data = [strin dataUsingEncoding:NSUTF8StringEncoding];
相關文章
相關標籤/搜索