gpt4 book ai didi

iphone - NSLocalizedStringFromTable 崩溃

转载 作者:行者123 更新时间:2023-12-02 07:39:07 25 4
gpt4 key购买 nike

我使用 txts 文件中的按钮文本创建 UIActionSheet。将 NSZombieEnabled、NSDebuEnabled 设置为 YES 并将 NSDallocateZombies 设置为 NO 后,我收到一个断点,并显示以下消息:

*** -[CFString isEqual:]: message sent to deallocated instance 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]: message sent to deallocated instance

你遇到过这样的问题吗?重复从资源中获取字符串是错误的吗?作为最后一个解决方案,我想将它们放入成员变量中一次,从而避免对相同文本再次调用 NSLocalizedStringFromTable。

最佳答案

最终在其他地方发现了问题:通过 NSLocalizedStringFromTable 获取的 NSString 后来被释放了尽管没有对其进行保留。有趣的是,崩溃发生在系统框架内一个完全不同的类中。所以看来,过度释放才是根本原因。

关于iphone - NSLocalizedStringFromTable 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2198576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com