我有一个运行良好的应用程序。但我需要没有内存泄漏。所以我决定用分析器构建,然后我看到了很多小的内存管理问题。我整理了除了这个之外的几乎所有东西。这里我的单元格对象是显示为泄漏的对象,但实际上我不知道我在哪里走错了。这是我的cellforRowatIndexpath
方法。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:EventCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:EventCellIdentifier];
UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cell_with_arrow.png"]];
[cell setBackgroundView:img];
[img release];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; // Pre-iOS6 use UILineBreakModeWordWrap
cell.textLabel.numberOfLines =0;
[cell.textLabel sizeToFit];
}
[[cell viewWithTag:12] removeFromSuperview];
[[cell viewWithTag:13] removeFromSuperview];
PTPusherEvent *event = [eventsReceived objectAtIndex:indexPath.row];
//cell.textLabel.text = event.name;
// cell.detailTextLabel.text = [event.data description];
NSDictionary *payload =event.data;
NSLog(@"%@",payload);
NSString *tes=[payload objectForKey:@"from"];
NSString *subtitle = [NSString stringWithString: @"From "];
subtitle = [subtitle stringByAppendingFormat:@"%@",tes];
cell.detailTextLabel.text = subtitle;
cell.textLabel.text = [payload objectForKey:@"message"];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
// [dateFormat setDateFormat:@"dd-MMM-YYYY HH:mm:ss"];
[dateFormat setDateFormat:@"dd-MMM-YYYY hh:mm a"];
[dateFormat setTimeZone:[NSTimeZone defaultTimeZone]];
NSDate *todaysdate=[NSDate date];
NSString *todaysdateString = [dateFormat stringFromDate:todaysdate];
[dateFormat release];
CGSize boundingSize = CGSizeMake(320, CGFLOAT_MAX);
CGSize requiredSize = [cell.textLabel.text sizeWithFont:cell.textLabel.font
constrainedToSize:boundingSize
lineBreakMode:UILineBreakModeWordWrap];
CGFloat requiredHeight = requiredSize.height;
MarqueeLabel *rateLabelOne = [[MarqueeLabel alloc] initWithFrame:CGRectMake(115, requiredHeight+15,155, 20) rate:50.0f andFadeLength:10.0f];
rateLabelOne.numberOfLines = 1;
rateLabelOne.marqueeType = MLContinuous;
rateLabelOne.opaque = NO;
rateLabelOne.enabled = YES;
rateLabelOne.shadowOffset = CGSizeMake(0.0, -1.0);
rateLabelOne.textAlignment = UITextAlignmentRight;
rateLabelOne.textColor = [UIColor redColor];
rateLabelOne.backgroundColor = [UIColor clearColor];
rateLabelOne.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.000];
rateLabelOne.text = @"OFFline!cannot communicate now.....";
MarqueeLabel *rateLabelTwo = [[MarqueeLabel alloc] initWithFrame:CGRectMake(215, requiredHeight+15,100, 20) rate:50.0f andFadeLength:10.0f];
rateLabelTwo.marqueeType = MLContinuous;
rateLabelTwo.numberOfLines = 1;
rateLabelTwo.opaque = NO;
rateLabelTwo.enabled = YES;
rateLabelTwo.shadowOffset = CGSizeMake(0.0, -1.0);
rateLabelTwo.textAlignment = UITextAlignmentRight;
rateLabelTwo.textColor = [UIColor blueColor];
rateLabelTwo.backgroundColor = [UIColor clearColor];
rateLabelTwo.font = [UIFont fontWithName:@"Helvetica" size:12.000];
rateLabelTwo.text = todaysdateString;
if([chatstatus isEqualToString:@"online"])
{
rateLabelTwo.tag=12;
[cell addSubview:rateLabelTwo];
[rateLabelTwo release];
}
else
{
rateLabelOne.tag=13;
[cell addSubview:rateLabelOne];
[rateLabelOne release];
}
return cell;
}
谁能帮我找出那个怪物在哪里?