美文网首页
(添加类别)decode解码

(添加类别)decode解码

作者: 又又轻 | 来源:发表于2016-11-23 09:24 被阅读37次

    - (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解码

          本文链接:https://www.haomeiwen.com/subject/wcnmpttx.html