(1) NSArray打印汉字
通过重载NSArray的- (NSString
*)descriptionWithLocale:(id)locale方法
方法体例如以下:
//依据设置的locale
进行连接数组
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *str = [NSMutableString
stringWithFormat:@"%lu (\n", (unsigned
long)self.count];
for (id obj
in self) {
[str
appendFormat:@"\t%@, \n", obj];
}
[str
appendString:@")"];
return str;
}
main.h
NSArray *array = [[NSArray
alloc] initWithObjects:@"语文",@"数学",@"英语",nil];//定义一个数组
NSLog(@"%@",array);
打印例如以下:
015-07-17 20:34:10.914 KVC使用及键值链的操作[1098:67924] 1 (
3 (
语文,
数学,
英语,
),
)