任何想法为什么下面的行会泄漏内存?这条线为什么会泄漏内存?
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:person.imageURL]];
的方法的cellForRowAtIndexPath内:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PersonCell"];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"PersonCell"] autorelease];
}
Person *person = [[Person alloc] initWithUserName:[people objectAtIndex:indexPath.row]];
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:person.imageURL]];
cell.textLabel.text = [people objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
[person release];
return cell;
}
这里是从person.m相关方法
- (NSURL*) imageURL
{
return [NSURL URLWithString:[userInfo valueForKey:@"profile_image_url"]];
}
编辑:添加init方法:
- (id)initWithUserName:(NSString *)user{
userName = [user copy];
userInfo = [[TwitterHelper fetchInfoForUsername:userName] retain];
updates = [[TwitterHelper fetchTimelineForUsername:userName] retain];
return self;
}
你怎么知道它在泄漏?正如杰森所说的那样, – 2009-09-09 21:36:10
;你怎么确定它正在泄漏?你使用了什么工具? – bbum 2009-09-09 22:00:01
我正在仪器上运行它来观察泄漏。这就是这些工具正在报告的内容。 – Jason 2009-09-10 13:15:01