自定义UITableViewCell类dealloc未调用

时间:2012-03-21 06:18:03

标签: objective-c

这是方法

我已经使用了UIViewController类型类,并在类中添加了所有委托和数据源,并将tableView添加到了IBB的

in .h

IBOutlet UITableView *listView_;

@property (nonatomic,retain) UITableView *listView;

in .m

@synthesize listView = listView_;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FWMessageCell *cell = nil;
cell = (FWMessageCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[FWMessageCell alloc] initWithStyle:UITableViewCellStyleDefault    
reuseIdentifier:cellIdentifier] autorelease];
}
[cell setMessage:message];
return cell;
}

- (void) dealloc {
  self.listView = nil;// my tableView
  [super dealloc];
}

和UITableViewCell类

- (void) dealloc {
  [message_ release], message_ = nil;
  [super dealloc];
}

我的问题是当我导航到第一个dealloc被调用但是没有调用单元类dealloc。

1 个答案:

答案 0 :(得分:0)

cell = [[[FWMessageCell alloc] initWithStyle:UITableViewCellStyleDefault    
reuseIdentifier:cellIdentifier] autorelease];

这意味着您的单元格被放置在Application Kit创建的自动释放池中。我假设您正在使用某种UINavigationController并导航回来。只有在游泳池排水时,您的牢房才会被解除分配。导航回来时不需要这样做。至于何时发生,请查看文档:

  

Application Kit在事件循环的每个循环开始时在主线程上创建一个自动释放池,并在最后将其排出,从而释放处理事件时生成的任何自动释放的对象。

http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html

相关问题