tabBar crash

3 views
Skip to first unread message
Message has been deleted

iHello

unread,
Oct 8, 2009, 8:52:47 AM10/8/09
to LiquidGear
I use tabBar and when I start my app it sometimes crashes (sometimes
showing 2 tabs instead 3):

Interval Since Last Report: 114379 sec
Crashes Since Last Report: 25
Per-App Interval Since Last Report: 0 sec
Per-App Crashes Since Last Report: 20
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread: 0
Application Specific Information:
iPhone Simulator 3.0 (138), iPhone OS 3.0 (7A341)
*** Terminating app due to uncaught exception 'NSRangeException',
reason: '*** -[NSCFArray insertObject:atIndex:]: index (1) beyond
bounds (1)'
Thread 0 Crashed:
0 CoreFoundation 0x302ac924
___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ + 4
1 libobjc.A.dylib 0x94045e3b
objc_exception_throw +
40
2 CoreFoundation 0x3028e5fb +[NSException
raise:format:arguments:] + 155
3 CoreFoundation 0x3028e55a +[NSException
raise:format:] + 58
4 Foundation 0x305684e9
_NSArrayRaiseBoundException + 121
5 Foundation 0x30505b05 -[NSCFArray
insertObject:atIndex:] + 85
...................

I think problem here:

- (void)addTab:(int)num title:(NSString *)title icon:(NSString *)icon
callback:(NSString *)callback {
NSDictionary *tabObj = [NSDictionary
dictionaryWithObjectsAndKeys:

[NSString stringWithFormat:@"%d", num], @"num",

title, @"title",

icon, @"icon",

callback, @"callback",

nil
];
[tabButtons insertObject:tabObj atIndex:num-1];
if(num > 0 && num <= 5 && [tabButtons count] > 0) {
[self resetTabs];
}
}

- (void)removeTab:(int)num {
if(num <= [tabButtons count] && num-1 > 0) {
[tabButtons removeObjectAtIndex:num-1];
[self resetTabs];
}

iHello

unread,
Oct 9, 2009, 11:04:15 AM10/9/09
to LiquidGear
I have solved this exception by adding object with addObject instead
insertObject, but now it shows
on every 15-20th run sometimes 3 and sometimes 2 tabs (if 3 defined).

Please help.

iHello

unread,
Oct 9, 2009, 10:32:03 PM10/9/09
to LiquidGear
I think this is not right:

if(num > 0 && num <= 5 && [tabButtons count] >0) {
[self resetTabs];
}

Anyone can help to solve this bug?

iHello

unread,
Oct 9, 2009, 11:02:33 PM10/9/09
to LiquidGear
or it can be the problem with memory... sometimes shows 3 Tabs,
sometimes 2 and sometimes 1 tab only :(
Reply all
Reply to author
Forward
0 new messages