NSArray打印汉字的方法

时间:2015-07-18 15:41:17   收藏:0   阅读:104

(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 (

语文

数学

英语

), 

)


版权声明:本文为博主原创文章,未经博主允许不得转载。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!