(添加类别)decode解码

- (NSString *)stringByUrlDecode

{

NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@"+" withString:@" "];

result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

return result;

}



NSString *decodedString=(__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (__bridge CFStringRef)apsDic[@"alert"], CFSTR(""), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));


//把排列成字典形状的字符串转化为字典

NSData *JSONData = [decodedString dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableLeaves error:nil];

你可能感兴趣的:((添加类别)decode解码)