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

语文

数学

英语

), 

)


相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-11-20
  • 2021-05-01
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2021-05-23
  • 2021-12-06
相关资源
相似解决方案