在给系统类创建分类时,如果只是重写类的方法,而没有新增方法,则可以在工程中只引入.m文件。但要记得#import相应的系统框架。如下:
#import <Foundation/Foundation.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
网友评论