Reputation: 6377
I'm getting a memory warning: "Incorrect decrement of the reference count of an object that is not owned at this point by the caller" for challengeCell at the marked line.
myIdentifier = @"ChallengTblVwCell";
ChallengeTableViewCell *challengeCell = (ChallengeTableViewCell *)[tableView dequeueReusableCellWithIdentifier:myIdentifier];
if( challengeCell == nil )
{
[[ NSBundle mainBundle ] loadNibNamed:@"ChallengeTableViewCell" owner:self options:nil ];
challengeCell = challengeTblCell;
}
else {
//some code
}
challengeInstance = [genericArray objectAtIndex:indexPath.row];
NSString *challengeTitle = challengeInstance.elecompany;
[challengeCell initWithTitle:challengeTitle subTitle:challengeSubtitle _votes:challengeVotes content:challengeContent _time:challengeTime _image:challengeImage noComments:challengeCommentsNo]; //Warning coming at this line
return (UITableViewCell *)challengeCell;
EDIT:
-(id)initWithTitle:(NSString *)_title content:(NSString *)_content fromName:(NSString *)_fromName _time:(NSString *)_time_ _image:(NSString *)_image_ noComments:(NSInteger)commentsNo
{
//Labels are created through interface builder
[_lbltitle_ setText:_title];
[_lbltime setText:_time_];
[lblcontent setText:_content];
[lblsubTitle setText:_fromName];
[lblnoOfComments setText:[NSString stringWithFormat:@"%d",commentsNo]];
// code for adjusting label height according to content.
return self;
}
I made this separate class for management of cell to make its manipulation easy.
Can anybody please help me resolve this?
Thanx in advance.
Upvotes: 1
Views: 1359
Reputation: 18741
It will be better if you post your code for initWithTitle for these 2 lines:
[challengeCell initWithTitle:challengeTitle subTitle:challengeSubtitle _votes:challengeVotes content:challengeContent _time:challengeTime _image:challengeImage noComments:challengeCommentsNo]; //Warning coming at this line
return (UITableViewCell *)challengeCell;
But what I guess is that you already have a challengeCell
object, already alloc-ed and init-ed. Your code looks really strange to be honest. Usually, what people do will be [[UIChallengeCell alloc] initWithTitle...]
not from the instance itself. I think this creates your problem.
What you should do is set the property yourself.
challengeCell.challengeTitle = challengeTitle;
challengeCell.subTitle = challengeSubtitle;
Upvotes: 1