0
다음 코드가 누수를 일으키는 이유에 대해 이해하려고합니다. 그래서 다음과 같은 사용자 정의 init 메소드가 있습니다.초기화에서 메모리 누수 디버깅
@property (nonatomic, retain) NSString *userId;
@property (nonatomic, retain) NSString *text;
@property (nonatomic, retain) NSString *username;
@property (nonatomic, retain) NSString *creatorName;
@property (nonatomic, retain) NSString *profilePicture;
@property (nonatomic, retain) NSString *imageId;
@property (nonatomic, retain) NSString *imageLink;
@property (nonatomic, retain) NSString *createdTime;
@property (nonatomic, retain) NSMutableArray * imageLikes;
@property (nonatomic, retain) NSMutableArray * imageComments;
@property (nonatomic, retain) NSDictionary *image;
@property (nonatomic, assign) int commentsCount;
@property (nonatomic, assign) int likesCount;
@property (nonatomic, assign) int index;
@property (nonatomic, assign) int numberOfRows;
@property (nonatomic, assign) BOOL increaseHeight;
@property (nonatomic, assign) BOOL userHasLiked;
@property (nonatomic, assign) BOOL canResetHeight;
-(id)initWithData:(NSDictionary *)data
{
self = [super init];
if (!self) {
return nil;
}
self.text = [[data valueForKey:@"caption"] valueForKey:@"text"];
self.createdTime = [[data valueForKey:@"caption"] valueForKey:@"created_time"];
self.imageId = [data valueForKey:@"id"];
self.imageLink = [data valueForKey:@"link"];
NSDictionary *from = [data valueForKey:@"user"];
self.username = [from valueForKey:@"username"];
self.profilePicture = [from valueForKey:@"profile_picture"];
self.creatorName = [from valueForKey:@"full_name"];
self.userId = [from valueForKey:@"id"];
self.userHasLiked = [[data objectForKey:@"user_has_liked"] boolValue];
self.commentsCount = [[[data valueForKey:@"comments"] valueForKey:@"count"] intValue];
self.likesCount = [[[data valueForKey:@"likes"] valueForKey:@"count"] intValue];
self.image = [data valueForKey:@"images"];
self.increaseHeight = NO;
self.numberOfRows = -1;
return self;
}
-(void) dealloc
{
[createdTime_ release];
[imageLink_ release];
[imageId_ release];
[imageLikes_ release];
[imageComments_ release];
[username_ release];
[userId_ release];
[profilePicture_ release];
[text_ release];
[creatorName_ release];
[super dealloc];
}
어떤 아이디어가 있습니까? 나보다 더 빨리 것에 대한
당신에게
1 ... 또한, [당신은 *** *** 초기화와 할당 해제의 방법에 속성 접근을 사용하지 않아야합니다, @adit합니다 (HTTP : // 유래. 질문/192721/why-shouldnt-i-use-objective-c-2-0-access-in-init-dealloc). –
@MichaelDautermann 이유 설명? – adit
거기에 내 의견에 포함 된 링크를 클릭하십시오. –