摘要:
1.声明类别@interface NSString (NumberConvenience)-(NSNumber *) lengthAsNumber;@end该声明表示,类别的名称是NumberConvenience,而且该类别将向NSString类中添加方法。2.实现类别@implementation NSString (NumberConvenience)-(NSNumber *) lengthAsNumber{ unsigned int length = [self length]; return ([NSNumber numberWithUnsignedInt: length]);}例1 阅读全文