iOS 让Xcode打印汉字, 而不是UTF8编码

来源:互联网 发布:中国网络漫画家收入 编辑:程序博客网 时间:2024/06/03 13:30

http://blog.csdn.net/Cloud_Pro/article/details/53391656


为NSArray添加分类


  1. #import "NSArray+decription.h"  
  2.   
  3. @implementation NSArray (decription)  
  4.   
  5. - (NSString *)descriptionWithLocale:(id)locale  
  6. {  
  7.     NSMutableString *str = [NSMutableString stringWithFormat:@"%lu (\n", (unsigned long)self.count];  
  8.       
  9.     for (id obj in self) {  
  10.         [str appendFormat:@"\t%@, \n", obj];  
  11.     }  
  12.       
  13.     [str appendString:@")"];  
  14.       
  15.     return str;  
  16. }  
  17.   
  18. @end  

为NSDictionary添加分类

  1. #import "NSDictionary+decription.h"  
  2.   
  3. @implementation NSDictionary (decription)  
  4.   
  5. - (NSString *)descriptionWithLocale:(id)locale  
  6. {  
  7.     NSArray *allKeys = [self allKeys];  
  8.     NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"{\t\n "];  
  9.     for (NSString *key in allKeys) {  
  10.         id value= self[key];  
  11.         [str appendFormat:@"\t \"%@\" = %@,\n",key, value];  
  12.     }  
  13.     [str appendString:@"}"];  
  14.       
  15.     return str;  
  16. }  
  17.   
  18. @end  

原创粉丝点击