美文网首页
iOS打印数组和字典里的汉字

iOS打印数组和字典里的汉字

作者: _moses | 来源:发表于2017-12-15 13:47 被阅读23次

    首先,分别给数组和字典创建一个分类
    然后,把下面的代码分别复制到两个分类的.m文件中即可

    - (NSString *)descriptionWithLocale:(id)locale {
        NSString *desc = [self.description stringByReplacingOccurrencesOfString:@"\\\"" withString:@"ms_desc_value_str1"];
        desc = [desc stringByReplacingOccurrencesOfString:@"\\n" withString:@"ms_desc_value_str2"];
        desc = [desc stringByReplacingOccurrencesOfString:@"\\r" withString:@"ms_desc_value_str3"];
        desc = [desc stringByReplacingOccurrencesOfString:@"\"" withString:@"ms_desc_value_str4"];
        desc = [NSString stringWithCString:[desc cStringUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding];
        desc = [desc stringByReplacingOccurrencesOfString:@"ms_desc_value_str1" withString:@"\""];
        desc = [desc stringByReplacingOccurrencesOfString:@"ms_desc_value_str2" withString:@"\n"];
        desc = [desc stringByReplacingOccurrencesOfString:@"ms_desc_value_str3" withString:@"\r"];
        return [desc stringByReplacingOccurrencesOfString:@"ms_desc_value_str4" withString:@"\""];
    }
    

    相关文章

      网友评论

          本文标题:iOS打印数组和字典里的汉字

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