Objective c UITableViewController僵尸在滚动
星期五快乐。调试一个僵尸问题很有趣。我有一个Objective c UITableViewController僵尸在滚动,objective-c,ios,uitableview,scroll,nszombie,Objective C,Ios,Uitableview,Scroll,Nszombie,星期五快乐。调试一个僵尸问题很有趣。我有一个UITableView,它从加载了Word对象的NSMutableArray获取数据源。(见下面的课程)。当应用程序加载时,一切正常-前8或9个单词按预期显示在表视图中。但是,当我滚动时,我在Word对象中得到了僵尸,这在调试器输出“”中证明为Word类实例变量值的值。(见截图)。这导致了一场车祸 TableSearch[12440:207] *** -[CFString respondsToSelector:]: message sent to de
UITableView
,它从加载了Word
对象的NSMutableArray
获取数据源。(见下面的课程)。当应用程序加载时,一切正常-前8或9个单词按预期显示在表视图中。但是,当我滚动时,我在Word
对象中得到了僵尸,这在调试器输出“”中证明为Word
类实例变量值的值。(见截图)。这导致了一场车祸
TableSearch[12440:207] *** -[CFString respondsToSelector:]: message sent to deallocated instance 0x6b1fe70
这是单词class
//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类的“word”和“definition”属性是否都定义为“retain”?例如
如果您将它们写成:
@property (nonatomic, assign) NSString *word;
或者只是
@property (nonatomic) NSString *word;
那就可以解释你的车祸了。是的,就是这样。实例变量被定义为:@property(非原子,赋值)NSString*word;谢谢
@property (nonatomic) NSString *word;