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