0

I am trying to make sense, on why the following code is causing leaks. So I have the following custom init method:

@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];
}

Any idea why?

adit
  • 32,574
  • 72
  • 229
  • 373

1 Answers1

1
-(void) dealloc
{
    [createdTime_ release];
    [imageLink_ release];
    [imageId_ release];
    [imageLikes_ release];
    [imageComments_ release];
    [username_ release];
    [userId_ release];
    [profilePicture_ release];
    [text_ release];
    [creatorName_ release];
    [image_ release]; // add a code
    [super dealloc];
}
bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
  • +1 to you for being faster than me... also, to @adit, [you should ***NOT*** use property accessors in init and dealloc methods](http://stackoverflow.com/questions/192721/why-shouldnt-i-use-objective-c-2-0-accessors-in-init-dealloc). – Michael Dautermann Jul 26 '12 at 04:23
  • click on the link I included in my comment up there. – Michael Dautermann Jul 26 '12 at 04:45