When we request interface, the server returns some data, when we will find print, print out a unicode code, not the characters.
This time the need to manually handle ourselves and let the printed output when the Chinese character format.
Methods as below:
Add a classification, the classification process described rewritten as follows:
/** * 集合类型打log */ @implementation NSArray (log) - (NSString *)description{ return [self descriptionWithLocale:nil]; } - (NSString *)descriptionWithLocale:(id)locale{ NSMutableString * string = [[NSMutableString alloc]init]; [string appendString:@"[\n"]; for (int i = 0; i < self.count; i++) { [string appendFormat:@"\t第%d个 -- %@ \n", I, Self [I]]; } [ String stringByAppendingString: @ " ] \ n- " ]; return String ; } @end @implementation NSDictionary (the Log) - (NSString * ) jsonDescription { // reference to this blog https: / /www.jianshu.com/p/f14b4cb1435b . // NSString default is UTF-16, UTF-8 can be transferred out of printing the NSError * error = nil; NSData * = Data [NSJSONSerialization dataWithJSONObject: Self Options: error NSJSONWritingPrettyPrinted : & error]; IF (error) { the NSMutableString*strM = [NSMutableString stringWithString:@"{\n"]; [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [strM appendFormat:@"\t%@ = %@ ;\n", key, obj]; }]; [strM appendString:@"}\n"]; return strM; } NSString *newString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; newString = [newString stringByReplacingOccurrencesOfString:@"\\" withString:@""]; Return of newString; } - (NSString * ) Description { return [Self descriptionWithLocale: nil]; } - (NSString * ) descriptionWithLocale: (ID) the locale { IF ([NSJSONSerialization isValidJSONObject: Self]) { return [Self jsonDescription]; } // originally written, the format of a problem, but no problem in Chinese turn the NSMutableString STRM * = [the NSMutableString stringWithString: @ " {\ n- " ]; [Self enumerateKeysAndObjectsUsingBlock: ^ (Key ID, ID obj, BOOL * STOP ) { [STRM AppendFormat: @ " \ T% = @% @; \ n-", key, obj]; }]; [strM appendString:@"}\n"]; return strM; } @end