首先想到的方法是在description方法中重新遍历修改, 这里推荐字符串处理Unicode编码的方式.
首先还是在字典分类中覆盖原先的description方法, 这里的unicodeString方法是下一步需要实现的NSString分类对象方法
- (NSString *)descriptionWithLocale:(id)locale {
return self.description.unicodeString;
}
在NSString分类中实现字符串处理Unicode编码
- (NSString *)unicodeString {
// return @"kkkllpp";
NSString *tempStr1 = [self stringByReplacingOccurrencesOfString:@"\\u" withString:@"\\U"];
NSString *tempStr2 = [tempStr1 stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
NSString *tempStr3 = [[@"\"" stringByAppendingString:tempStr2] stringByAppendingString:@"\""];
NSData *tempData = [tempStr3 dataUsingEncoding:NSUTF8StringEncoding];
NSPropertyListFormat format = NSPropertyListOpenStepFormat;
/* Create a property list from an NSData. The options can be any of NSPropertyListMutabilityOptions. If the format parameter is non-NULL, it will be filled out with the format that the property list was stored in. If an error occurs the return value will be nil and the error parameter (if non-NULL) set to an autoreleased NSError describing the problem.
*/
return [NSPropertyListSerialization propertyListWithData:tempData options:NSPropertyListImmutable format:&format error:nil];
// return [returnStr stringByReplacingOccurrencesOfString:@"\\r\\n" withString:@"\n"];
}
最后用到的属性列表序列化函数, 没有大神指点很难想到