我使用 txts 文件中的按钮文本创建了一个 UIActionSheet。在我将 NSZombieEnabled、NSDebuEnabled 设置为 YES 并将 NSDeallocateZombies 设置为 NO 后,我得到一个带有以下消息的断点:
*** -[CFString isEqual:]: 消息发送到已释放实例 0x11fae00
这发生在第三次或第四次显示 UIActionSheet 之后,而不是立即显示。发生这种情况的代码是:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedStringFromTable( @"text", @"class", @"text" )
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedStringFromTable( @"text1", @"class", @"text1" ),
NSLocalizedStringFromTable( @"text2", @"class", @"text2" ),
NSLocalizedStringFromTable( @"text3", @"class", @"text3" ), nil];
[actionSheet showFromTabBar:self.tabBarController.tabBar];
[actionSheet release];
如果我删除 NSDealocateZombies,模拟器中不会再出现崩溃,但我会在控制台中收到警告:
[CFString _cfTypeID]:消息发送到释放的实例
你遇到过这样的问题吗?从资源中重复获取字符串是错误的吗?作为最后一个解决方案,我想将它们放在成员变量中一次,从而避免对 NSLocalizedStringFromTable 再次调用相同的文本。