0

I have a tab bar, and I'm trying to remove an item's badge value by setting it to nil. However, sometimes, I'm getting an EXC_BAD_ACCESS error. The main thread is suspended after the exception, and I'm poing:

(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

This appears to happen randomly, at least, I haven't found a specific pattern yet. However, it doesn't make any sense. Is this a bug?

UPDATE: Oops, I tried to set numbers instead of strings in debugger above, where it's normal to throw, but the original problem still applies.

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • `nil` is the default value of `badgeValue` as per documentation. So the reason must be somewhere else... you said that you pass a valid string? – croX Feb 17 '15 at 13:03

1 Answers1

0

You should use

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

Here is the link for your reference

Community
  • 1
  • 1