摘要:
1.例子:AddressCard.h接口文件#import<Foundation/Foundation.h>@interface AddressCard:NSObject<NSCoding,NSCoping>@property (copy,nonatomic) NSString *name,email;-(void)setName:(NSString) *theName andEmail:(NSString *)theEmail;-(NSComparisonResult) compareNames:(id)element;-(void)print;AddressCard 阅读全文
摘要:
@interface Fraction:NSObject<NSCopying>-(id)copyWithZone:(NSZone*)zone{ Fraction *newFract = [[Fraction allocWithZone:zone]init];//如果Fraction类有子类, //应改为 id newFract = [[self class] allocWithZone:zone] init];// [newFract setTo:numerator over:denominator]; return newFract;} 阅读全文