标签:des style blog io color os ar for sp
在iOS开发中,经常需要查看数组中得元素是否是自己想要的,但是苹果并没有对直接打印数组中得中文作处理,直接打印就会出现一堆很讨厌的东西,解决其实很简单,就是需要通过为NSArray添加分类,重写 - (NSString *)descriptionWithLocale:(id)locale方法即可
代码如下:
#import "NSArray+Log.h" @implementation NSArray (Log) - (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; } @end
标签:des style blog io color os ar for sp
原文地址:http://www.cnblogs.com/pretty-guy/p/4054924.html