开发者

NSLocalizedStringFromTable crash

开发者 https://www.devze.com 2022-12-18 21:55 出处:网络
I create a UIActionSheet with button texts from a txts file. After I set NSZombieEnabled, NSDebuEnabled to YES and NSDeallocateZombies to NO, I get a breakpoint with the message:

I create a UIActionSheet with button texts from a txts file. After I set NSZombieEnabled, NSDebuEnabled to YES and NSDeallocateZombies to NO, I get a breakpoint with the message:

*** -[CFString isEqual:]: message sent to deallocated instance 0x11fae00

This happens after showing for the third or fourth time the UIActionSheet, not immediatelly. The code were this happens is:

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];

If I remove NSDealocateZombies, there are no more crashes in the simulator, but I get warnings in the console:

[CFString _cfTypeID]: message sent to deallocated instance

Did you encountered such problems? Is it wrong to get repeatedly the strings from the resource? As a last solution, I was thinking to put them in member variables once, thus avoiding another calll to NSLocalizedStringFromTable for the same text.


Eventually found the problem somewhere else: a NSString obtained through NSLocalizedStringFromTable was later released although there was no retain done on it. The fun part is that the crash was happening inside the system framework in a completely different class. So it seems that over-releasing was the cause after all.

0

精彩评论

暂无评论...
验证码 换一张
取 消