1.问题:
NSArray *array = [NSArray arrayWithObjects:@"我",@"在",@"鼓楼", nil]; NSLog(@"%@",array); NSDictionary *dictionary = @{@"我":@"yin",@"地点":@"gulou"}; NSLog(@"%@",dictionary);
打印结果:
( "U6211", "U5728", "U9f13U697c" ) 2016-03-18 17:58:09.162 aiya[11591:1129321] { "U5730U70b9" = gulou; "U6211" = yin; }
解决办法:给它们写个分类就可以了
#import <Foundation/Foundation.h> @implementation NSDictionary (Log) - (NSString *)descriptionWithLocale:(id)locale { NSMutableString *string = [NSMutableString string]; [string appendString:@"{ "]; [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [string appendFormat:@" %@", key]; [string appendString:@" : "]; [string appendFormat:@"%@, ", obj]; }]; [string appendString:@"}"]; NSRange range = [string rangeOfString:@"," options:NSBackwardsSearch]; if (range.location != NSNotFound) [string deleteCharactersInRange:range]; return string; } @end @implementation NSArray (Log) - (NSString *)descriptionWithLocale:(id)locale { NSMutableString *string = [NSMutableString string]; [string appendString:@"[ "]; [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [string appendFormat:@" %@, ", obj]; }]; [string appendString:@"]"]; NSRange range = [string rangeOfString:@"," options:NSBackwardsSearch]; if (range.location != NSNotFound) [string deleteCharactersInRange:range]; return string; } @end
效果如下:
[ 我, 在, 鼓楼 ] 2016-03-18 18:13:27.094 aiya[11666:1139288] { 我 : yin, 地点 : gulou }
调试的时候有木有很方便呢~