之前我一直没注意过,今天在instruments中运行发现我写的copyWithZone 都有leaks,比如一个很简单的类:
.h 里面
@interface PostImageModal : NSObject{
NSString *small;
NSString *medium;
NSString *big;
}
@property (nonatomic,copy) NSString *small;
@property (nonatomic,copy) NSString *medium;
@property (nonatomic,copy) NSString *big;
@end
.m 里面
@implementation PostImageModal
@synthesize small;
@synthesize medium;
@synthesize big;
-(id)copyWithZone:(NSZone*)zone{
PostImageModal *copy=[[[self class] allocWithZone:zone]init];
copy.small=small;
copy.medium=medium;
copy.big=big;
return copy;
}
-(void)dealloc{
[small release];
[medium release];
[big release];
[super dealloc];
}
@end
运行的是instruments里提示 [PostImageModal copyWithZone:] leaks, 我不清楚哪里的问题啊,有人遇到么?
.h 里面
@interface PostImageModal : NSObject{
NSString *small;
NSString *medium;
NSString *big;
}
@property (nonatomic,copy) NSString *small;
@property (nonatomic,copy) NSString *medium;
@property (nonatomic,copy) NSString *big;
@end
.m 里面
@implementation PostImageModal
@synthesize small;
@synthesize medium;
@synthesize big;
-(id)copyWithZone:(NSZone*)zone{
PostImageModal *copy=[[[self class] allocWithZone:zone]init];
copy.small=small;
copy.medium=medium;
copy.big=big;
return copy;
}
-(void)dealloc{
[small release];
[medium release];
[big release];
[super dealloc];
}
@end
运行的是instruments里提示 [PostImageModal copyWithZone:] leaks, 我不清楚哪里的问题啊,有人遇到么?