UITabBarItem setBadgeValue:nil抛出EXC_BAD_ACCESS

时间:2015-02-17 12:25:02

标签: ios objective-c uitabbarcontroller uitabbar uitabbaritem

我有一个标签栏,我试图通过将其设置为nil来删除项目的徽章值。但是,有时候,我收到EXC_BAD_ACCESS错误。异常后主线程被暂停,我po

(lldb) po [[self.tabBar items] objectAtIndex:2]
<UITabBarItem: 0x17015e980> //no problem with the class itself

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:0]
 nil

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:1]
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x1).
The process has been returned to the state before expression evaluation.

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:0]
 nil

这似乎是随机发生的,至少我还没有找到具体的模式。但是,它没有任何意义。这是一个错误吗?

更新:哎呀,我尝试在上面的调试器中设置数字而不是字符串,这是正常的抛出,但原始问题仍然适用。

1 个答案:

答案 0 :(得分:0)

你应该使用

[[self navigationController] tabBarItem].badgeValue = @"your-value";

Here is the link for your reference

相关问题