我有一个选项卡条,我试图通过将其设置为nil
来删除一个项的徽章值。但是,有时,我会收到一个EXC_BAD_ACCESS
错误。主线程在异常后挂起,我是po
ing:
(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
这似乎是随机发生的,至少,我还没有找到具体的模式。然而,这没有任何意义。这是个虫子吗?
UPDATE: Oops,我尝试在上面的调试器中设置数字而不是字符串,在这里抛出是正常的,但是原来的问题仍然适用。
发布于 2015-02-18 02:16:11
你应该用
[[self navigationController] tabBarItem].badgeValue = @"your-value";
https://stackoverflow.com/questions/28561435
复制