您的位置:首页 > 其它

打印字典和数组中的中文字符

2016-04-16 11:17 302 查看
#import <Foundation/Foundation.h>

@interface NSArray (Log)

@end

@interface NSDictionary (Log)

@end

#import "NSArray+Log.h"

@implementation NSArray (Log)

- (NSString *)descriptionWithLocale:(id)locale

{

NSMutableString *strM = [NSMutableString
stringWithString:@"(\n"];

[self enumerateObjectsUsingBlock:^(id obj,
NSUInteger idx, BOOL *stop) {

[strM appendFormat:@"\t%@,\n", obj];

}];

[strM appendString:@")"];

return strM;

}

@end

@implementation NSDictionary (Log)

- (NSString *)descriptionWithLocale:(id)locale

{

NSMutableString *strM = [NSMutableString
stringWithString:@"{\n"];

[self
enumerateKeysAndObjectsUsingBlock:^(id key,
id obj,
BOOL *stop) {

[strM appendFormat:@"\t%@ = %@;\n", key, obj];

}];

[strM appendString:@"}\n"];

return strM;

}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: