UITableViewController滚动的僵尸

问题描述:

快乐星期五。有一个有趣的时间调试僵尸问题。我有一个UITableView,它从NSMutableArray中获取其数据源,并加载Word对象。 (见下面的课)。当应用程序加载时,一切都很好 - 按预期在表格视图中显示前8或9个单词。但是当我滚动时,我在我的Word对象中获得僵尸,如在调试器输出“<Zombie>”中所证明的那样,作为Word类实例变量值的值。 (见截图)。这导致崩溃。UITableViewController滚动的僵尸

Screenshot showing zombies

TableSearch[12440:207] *** -[CFString respondsToSelector:]: message sent to deallocated instance 0x6b1fe70 

这里是Word类

//Word Class 

#import "Word.h" 

@implementation Word 

@synthesize word; 
@synthesize definition; 

+ (id)wordWith:(NSString *)word Definition:(NSString *)definition 
{ 

Word *newWord = [[[self alloc] init] autorelease]; 

    newWord.word = word; 
    newWord.definition = definition; 

    return newWord; 

} 


- (void)dealloc 
{ 
    [word release]; 
    [definition release]; 
    [super dealloc]; 
} 

@end 

我敢肯定这是愚蠢的事情,但我不能看到我错在哪里。

我对仪器进行了“分析”,没有发现任何问题。在崩溃后,我运行了“malloc_history 12440 0x6b1fe70”并查看了输出,但不知道要查找什么,除了 有僵尸的对象的类名,我没有看到。

任何帮助跟踪这一点非常感谢。

谢谢!

您的Word类的“单词”和“定义”属性是否都定义为“保留”?例如。

@property (nonatomic, retain) NSString *word; 
@property (nonatomic, retain) NSString *definition; 

如果你已经写了他们为:

@property (nonatomic, assign) NSString *word; 

或只是

@property (nonatomic) NSString *word; 

然后,它会占你的崩溃。

+0

是的,就是这样。实例变量定义为:@property(nonatomic,assign)NSString * word;谢谢 – Slinky 2012-02-03 15:43:01