UIApplicationMain crashing in xcode [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
My application is crashing as
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //Thread 1:signal SIGABRT
[pool release];
return retVal;
/*
int retVal = 0;
#autoreleasepool {
NSString *classString = NSStringFromClass([gTalkAppDelegate class]);
#try {
retVal = UIApplicationMain(argc, argv, nil, classString);
}
#catch (NSException *exception) {
NSLog(#"Exception - %#",[exception description]);
exit(EXIT_FAILURE);
}
}
return retVal;
*/
}
2014-01-07 15:41:25.881 testproject[28812:70b] -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184
2014-01-07 15:41:25.973 testproject[28812:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184'
*** First throw call stack:
(
0 CoreFoundation 0x026d75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c028b6 objc_exception_throw + 44
2 CoreFoundation 0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x026c790b ___forwarding___ + 1019
4 CoreFoundation 0x026c74ee _CF_forwarding_prep_0 + 14
5 testproject 0x0000e7cd -[SecondViewController showData] + 1837
6 testproject 0x0000829d -[SecondViewController viewDidAppear:] + 1261
7 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
8 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
9 UIKit 0x00898fca -[UINavigationController viewDidAppear:] + 191
10 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
11 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
12 UIKit 0x008a827b -[UITabBarController viewDidAppear:] + 113
13 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
14 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
15 UIKit 0x0087cb9f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
16 UIKit 0x0087b56a -[UIViewController _executeAfterAppearanceBlock] + 63
17 UIKit 0x007801a9 ___afterCACommitHandler_block_invoke_2 + 33
18 UIKit 0x0078012e _applyBlockToCFArrayCopiedToStack + 403
19 UIKit 0x0077ff7e _afterCACommitHandler + 568
20 CoreFoundation 0x0269f4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
21 CoreFoundation 0x0269f41f __CFRunLoopDoObservers + 399
22 CoreFoundation 0x0267d344 __CFRunLoopRun + 1076
23 CoreFoundation 0x0267cac3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x0267c8db CFRunLoopRunInMode + 123
25 GraphicsServices 0x035e09e2 GSEventRunModal + 192
26 GraphicsServices 0x035e0809 GSEventRun + 104
27 UIKit 0x00763d3b UIApplicationMain + 1225
28 testproject 0x0000213d main + 125
29 testproject 0x000020b5 start + 53
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
How can fix it.

Looking through your stacktrace you can see that in viewDidAppear you call a method called showData this can be seen from the two lines below.
5 gtalkhotdial 0x0000e7cd -[SecondViewController showData] + 1837
6 gtalkhotdial 0x0000829d -[SecondViewController viewDidAppear:] + 1261
Within this showData method you make a call to something (unfortunately we can't tell what) that tries to call -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: and what ever that object is it, it doesn't have this method. To tell you anything more we need to see what is in the method showData. But your crash is clearly happening in there. If you what to know anything else please share that method implementation.

Look at your stack trace, the lines
2 CoreFoundation 0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
and
5 gtalkhotdial 0x0000e7cd -[SecondViewController showData] + 1837
should help you

Related

iOS Thread 1 signal SIGABRT Error

I am getting the "Thread 1: Signal SIGABRT Error" in my code. I have tried to reload my code into a different XCode project, inserting the like of code into a try/catch block, cleaning and rebuilding the project, tried checking some of my connections on the storyboard and I still can get anything resolved here.
Here is the source code of the main.m file:
#import <UIKit/UIKit.h>
#import "SFAppDelegate.h"
int main(int argc, char * argv[]) {
#autoreleasepool {
#try {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([SFAppDelegate class]));
}
#catch (NSException *e) {
NSLog(#"CRASH: %#", e);
NSLog(#"Stack Trace: %#", [e callStackSymbols]);
}
}
}
The error is showing up on this line of code:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([SFAppDelegate class]));
The XCode console is showing the following errors:
*** First throw call stack:
(
0 CoreFoundation 0x000000010a032d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010967321e objc_exception_throw + 48
2 CoreFoundation 0x000000010a0a2f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000109fb8005 ___forwarding___ + 1013
4 CoreFoundation 0x0000000109fb7b88 _CF_forwarding_prep_0 + 120
5 ExApp 0x00000001060f954b -[Exercise getQuizResponseUrl] + 43
6 ExApp 0x0000000106117550 -[SFPreviewVideoView configureWithThumbnailProvider:duration:videoURLString:] + 816
7 ExApp 0x00000001061171bd -[SFPreviewVideoView configureWithThumbnailProvider:videoURLString:duration:delegate:] + 157
8 ExApp 0x00000001060cab6d -[SFQuestionsViewController tableView:cellForRowAtIndexPath:] + 1869
9 UIKit 0x0000000107a7e584 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 757
10 UIKit 0x0000000107a7e7e2 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
11 UIKit 0x0000000107a522b0 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3295
12 UIKit 0x0000000107a87b64 -[UITableView _performWithCachedTraitCollection:] + 110
13 UIKit 0x0000000107a6e3be -[UITableView layoutSubviews] + 222
14 UIKit 0x00000001079d5ab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
15 QuartzCore 0x0000000107602bf8 -[CALayer layoutSublayers] + 146
16 QuartzCore 0x00000001075f6440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
17 UIKit 0x00000001079c3928 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1509
18 ExApp 0x00000001060dd0b3 -[SFBrandingTableFooterView updateBrandingView:forTableView:updatelayout:] + 147
19 ExApp 0x00000001060dcd5e -[SFBrandingTableFooterView showBrandingFooterViewAndUpdateLayout:animated:] + 446
20 ExApp 0x00000001060ca0a4 __46-[SFQuestionsViewController refreshDataSource]_block_invoke.147 + 964
21 ExApp 0x00000001060d3c79 __41-[SFBrain requestObject:completionBlock:]_block_invoke_3 + 105
22 libdispatch.dylib 0x000000010b508978 _dispatch_call_block_and_release + 12
23 libdispatch.dylib 0x000000010b5320cd _dispatch_client_callout + 8
24 libdispatch.dylib 0x000000010b5128a4 _dispatch_main_queue_callback_4CF + 406
25 CoreFoundation 0x0000000109ff6e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
26 CoreFoundation 0x0000000109fbc37d __CFRunLoopRun + 2205
27 CoreFoundation 0x0000000109fbb884 CFRunLoopRunSpecific + 420
28 GraphicsServices 0x000000010dfbfa6f GSEventRunModal + 161
29 UIKit 0x0000000107910c68 UIApplicationMain + 159
30 ExApp 0x00000001060c532e main + 142
31 libdyld.dylib 0x000000010b57e68d start + 1
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Any help here would be greatly appreciated.
Either your code is not implemented [Exercise viewQuizResponseUrl] or [Exercise getQuizResponseUrl].. just check Exercise object is valid initialized or above methods are valid spell.

Need help interpreting a crash log from QuincyKit

I recently added QuincyKit (a crash log reporter that sits on top of PLCrashReporter) into an app and I received a crash log that I'm having trouble interpreting.
The crash log seems to be inconsistent - it says it was thread 0 that crashed, but the "Last Exception Backtrace" doesn't match with the thread 0 callstack. The last exception points to a table method, but thread 0 callstack indicates an abort occurred during the Quincy manager initialization.
Moreover, the "Last Exception Backtrace" doesn't seem to make much sense taken on it's own - the "canEditRowAtIndexPath" method doesn't even include a call to "removeObjectAtIndex" at all (see below for the method).
Can anyone shed any light onto whether or not I should be paying attention to the "Last Exception Backtrace" or is that a red herring, and I should really be looking into why PLCrashReporter aborted during start up?
Many thanks
Crash log excerpt:
Exception Type: SIGABRT
Exception Codes: #0 at 0x38362df0
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
Last Exception Backtrace:
0 CoreFoundation 0x29920fef <redacted> + 126
1 libobjc.A.dylib 0x37d0cc8b objc_exception_throw + 38
2 CoreFoundation 0x29833821 -[__NSArrayM removeObjectAtIndex:] + 0
3 DART 0x000906b3 -[DeliveryComplete tableView:canEditRowAtIndexPath:] + 262
4 UIKit 0x2d0a3c25 -[UITableView _canEditRowAtIndexPath:] + 60
5 UIKit 0x2d0a3a7f -[UITableView _setupCell:forEditing:atIndexPath:animated:updateSeparators:] + 130
6 UIKit 0x2d0a1179 <redacted> + 2320
7 UIKit 0x2cf82a31 +[UIView performWithoutAnimation:] + 72
8 UIKit 0x2d0a0861 -[UITableView _configureCellForDisplay:forIndexPath:] + 336
9 UIKit 0x2d246383 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 498
10 UIKit 0x2d24642f -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 54
11 UIKit 0x2d23b013 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2258
12 UIKit 0x2d049657 -[UITableView layoutSubviews] + 186
13 UIKit 0x2cf73023 -[UIView layoutSublayersOfLayer:] + 546
14 QuartzCore 0x2c993d99 -[CALayer layoutSublayers] + 128
15 QuartzCore 0x2c98f5cd <redacted> + 360
16 QuartzCore 0x2c98f455 <redacted> + 16
17 QuartzCore 0x2c98edf1 <redacted> + 224
18 QuartzCore 0x2c98ebdf <redacted> + 434
19 UIKit 0x2cf6b23b <redacted> + 126
20 CoreFoundation 0x298e6fed <redacted> + 20
21 CoreFoundation 0x298e46ab <redacted> + 278
22 CoreFoundation 0x298e4ab3 <redacted> + 914
23 CoreFoundation 0x29831201 CFRunLoopRunSpecific + 476
24 CoreFoundation 0x29831013 CFRunLoopRunInMode + 106
25 GraphicsServices 0x3100d201 GSEventRunModal + 136
26 UIKit 0x2cfd5a59 UIApplicationMain + 1440
27 DART 0x00015491 _mh_execute_header + 25745
28 libdyld.dylib 0x38298aaf <redacted> + 2
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x38362df0 __pthread_kill + 8
1 libsystem_c.dylib 0x382fe909 abort + 76
2 DART 0x00122dd7 -[PLCrashReporter enableCrashReporterAndReturnError:] + 1294
3 CoreFoundation 0x2992131f <redacted> + 630
4 libobjc.A.dylib 0x37d0cf13 <redacted> + 174
5 libc++abi.dylib 0x37643de3 <redacted> + 78
6 libc++abi.dylib 0x376438af __cxa_rethrow + 102
7 libobjc.A.dylib 0x37d0cdd3 objc_exception_rethrow + 42
8 CoreFoundation 0x2983129d CFRunLoopRunSpecific + 632
9 CoreFoundation 0x29831013 CFRunLoopRunInMode + 106
10 GraphicsServices 0x3100d201 GSEventRunModal + 136
11 UIKit 0x2cfd5a59 UIApplicationMain + 1440
12 DART 0x00015491 _mh_execute_header + 25745
13 libdyld.dylib 0x38298aaf <redacted> + 2
"canEditRowAtIndexPath" method:
-(BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag == SIGNER_TABLE_TAG_VALUE)
{
RouteStopData *currentStop = [CurrentRoute singleton].selectedStop;
NSArray *signers = [currentStop signerNamesForStop];
if (indexPath.row >= [signers count])
{
return NO;
}
if ([[signers objectAtIndex:indexPath.row] isEqualToString:DARK_DROP_SIGNER_STRING] ||
[[signers objectAtIndex:indexPath.row] isEqualToString:PAPER_INVOICE_SIGNER_STRING] ||
[[signers objectAtIndex:indexPath.row] isEqualToString:ADD_NEW_SIGNER_STRING]
)
{
return NO;
}
return YES;
}
return NO;
}
If you are using ios7, it's maybe UIKit's fault.
Tableview would like to call delegate method before dealloc.
So you can add this code in your Custom class:
- (void )dealloc{
self.tableView.dataSource = nil;
self.tableView.delegate = nil;
}
See more in iOS 7 bug or my bug in UIAlertView

signal SIGARBT error

I get this error if I'll run my App in the iOS Simulator (iPhone 4-inch 32-bit iOS 7.1):
Thread 1: signal SIGABRT
Error:
int main(int argc, char * argv[])
{
#autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
I hope someone can help me.
Console Report:
2014-04-26 14:09:24.039 Picxxr[2184:60b] -[ViewController filter1:]: unrecognized selector sent to instance 0x964d580
2014-04-26 14:09:24.041 Picxxr[2184:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController filter1:]: unrecognized selector sent to instance 0x964d580'
*** First throw call stack:
(
0 CoreFoundation 0x01d651e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01ae48e5 objc_exception_throw + 44
2 CoreFoundation 0x01e02243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01d5550b ___forwarding___ + 1019
4 CoreFoundation 0x01d550ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x01af6880 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x007a63b9 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x007a6345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x008a7bd1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x008a7fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x008a7243 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x00b3c2e3 _UIGestureRecognizerUpdate + 7166
12 UIKit 0x007e5a5a -[UIWindow _sendGesturesForEvent:] + 1291
13 UIKit 0x007e6971 -[UIWindow sendEvent:] + 1021
14 UIKit 0x007b85f2 -[UIApplication sendEvent:] + 242
15 UIKit 0x007a2353 _UIApplicationHandleEventQueue + 11455
16 CoreFoundation 0x01cee77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
17 CoreFoundation 0x01cee10b __CFRunLoopDoSources0 + 235
18 CoreFoundation 0x01d0b1ae __CFRunLoopRun + 910
19 CoreFoundation 0x01d0a9d3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x01d0a7eb CFRunLoopRunInMode + 123
21 GraphicsServices 0x032155ee GSEventRunModal + 192
22 GraphicsServices 0x0321542b GSEventRun + 104
23 UIKit 0x007a4f9b UIApplicationMain + 1225
24 Picxxr 0x0000cd7d main + 141
25 libdyld.dylib 0x03e0c701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Filter1 in a class called ViewController doesn't exist. You may have deleted an outlet or something from the code, but forgot to delete the link from the actual object in the storyboard. Right click on what was linked to Filter1 and see if it has the old (deleted) connection still.
It looks like you setup a button with an action of filter1: but you never added the filter1: method to your ViewController class.
Perhaps you defined the method as filter1 instead of filter1:. The colon makes a huge difference.
If your method is really:
- (IBAction)filter1 {
}
Then you need to change the button to use the selector filter1 instead of filter1:. Or change the method to:
- (IBAction)filter1:(id)sender {
}

SIGABRT error - segmented control

i have a segmented control which, depending on what is selected, is meant to allocate a value to a NS string, as follows:
-(IBAction)driverKnownIndexChanged{
switch (self.driverKnown.selectedSegmentIndex) {
case 0:
driverKnownResponse = #"Yes";
break;
case 1:
driverKnownResponse = #"No";
break;
default:
break;
}
}
however, it is throwing a SIGABRT at the following line:
#import "RoadSafetyAppAppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RoadSafetyAppAppDelegate class]));
}
}
and here is the console output:
2014-01-30 13:32:16.403 Road Safety App V2[3873:70b] -[DobInAHoonViewController driverKnown:]: unrecognized selector sent to instance 0xcd23440
2014-01-30 13:32:16.409 Road Safety App V2[3873:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DobInAHoonViewController driverKnown:]: unrecognized selector sent to instance 0xcd23440'
*** First throw call stack:
(
0 CoreFoundation 0x01d8f7e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01b0f8e5 objc_exception_throw + 44
2 CoreFoundation 0x01e2c843 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01d7fb0b ___forwarding___ + 1019
4 CoreFoundation 0x01d7f6ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x01b2182b -[NSObject performSelector:withObject:] + 70
6 UIKit 0x007d8309 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x007d8295 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x008d90a1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x008d9496 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x008d90d6 -[UIControl sendActionsForControlEvents:] + 48
11 UIKit 0x00947572 -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 598
12 UIKit 0x009498c3 -[UISegmentedControl touchesEnded:withEvent:] + 175
13 UIKit 0x00b6ccc3 _UIGestureRecognizerUpdate + 7166
14 UIKit 0x008177ca -[UIWindow _sendGesturesForEvent:] + 1291
15 UIKit 0x008186e1 -[UIWindow sendEvent:] + 1021
16 UIKit 0x007ea542 -[UIApplication sendEvent:] + 242
17 UIKit 0x007d42f3 _UIApplicationHandleEventQueue + 11455
18 CoreFoundation 0x01d18d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
19 CoreFoundation 0x01d1870b __CFRunLoopDoSources0 + 235
20 CoreFoundation 0x01d357ae __CFRunLoopRun + 910
21 CoreFoundation 0x01d34fd3 CFRunLoopRunSpecific + 467
22 CoreFoundation 0x01d34deb CFRunLoopRunInMode + 123
23 GraphicsServices 0x0344f4ed GSEventRunModal + 192
24 GraphicsServices 0x0344f32a GSEventRun + 104
25 UIKit 0x007d6eeb UIApplicationMain + 1225
26 Road Safety App V2 0x00002f9d main + 141
27 libdyld.dylib 0x0308470d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
and Ideas as to why i am having this problem? and a solution would also be appreciated.
This line switch (self.driverKnown.selectedSegmentIndex) { is accessing a property named driverKnown but that driver is unknown. The stack trace and exception are telling you that driverKnown is an undeclared or unknock getter method for the property.
The exception calls out DobInAHoonViewController which in that line of code would be the self. Is driverKnown suppose to be the name of your UISegmentedControl? Can we see the creation of said UISegmentedControl?
your method doesn't know selectedSegmentIndex . because you not value of segment value changed
UISegmentControl *mySegmentedControl = [[UISegmentControl alloc]init];
[mySegmentedControl addTarget:self action:#selector(segmentValueChanged:) forControlEvents:UIControlEventValueChanged];
- (IBAction)segmentValueChanged:(id)sender {
UISegmentedControl *driverKnown = (UISegmentedControl *)sender;
switch (driverKnown.selectedSegmentIndex) {
case 0:
driverKnownResponse = #"Yes";
break;
case 1:
driverKnownResponse = #"No";
break;
default:
break;
}
}

iOS: Sometimes app is terminated

My developing iOS application is sometimes terminated after the method addSubview: is called in the application delegate (but I'm not sure removeFromSuperview: also involved):
[self.tabBarController.view removeFromSuperview];
[self.window addSubview:navigationController.view];
What that showed in the log is:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x019b75a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01c41313 objc_exception_throw + 44
2 CoreFoundation 0x019ad0a5 -[__NSArrayM objectAtIndex:] + 261
3 <app_name> 0x000186dd -[TableViewController tableView:numberOfRowsInSection:] + 205
4 UIKit 0x00a742b7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1834
5 UIKit 0x00a71eb1 -[UITableViewRowData numberOfRowsInSection:] + 110
6 UIKit 0x00b60807 -[UISearchDisplayController _updateNoSearchResultsMessageVisiblity] + 115
7 Foundation 0x01029669 _nsnote_callback + 145
8 CoreFoundation 0x0198f9f9 __CFXNotificationPost_old + 745
9 CoreFoundation 0x0190e93a _CFXNotificationPostNotification + 186
10 Foundation 0x0101f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
11 UIKit 0x008df649 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 4581
12 UIKit 0x008d9254 -[UIWindow _setRotatableViewOrientation:duration:force:] + 89
13 UIKit 0x008db38f -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 794
14 UIKit 0x008d9081 -[UIWindow setDelegate:] + 252
15 UIKit 0x00964dee -[UIViewController _tryBecomeRootViewControllerInWindow:] + 106
16 UIKit 0x00975340 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 72
17 UIKit 0x008f0e4b -[UIView(Internal) _didMoveFromWindow:toWindow:] + 918
18 UIKit 0x008efa60 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166
19 UIKit 0x008e8750 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
20 UIKit 0x008e6aa3 -[UIView(Hierarchy) addSubview:] + 57
21 <app_name> 0x00004971 -[AppDelegate requestFinished:] + 993
22 <app_name> 0x0003e65b -[ASIHTTPRequest reportFinished] + 171
23 Foundation 0x0103e94e __NSThreadPerformPerform + 251
24 CoreFoundation 0x019988ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x018f688b __CFRunLoopDoSources0 + 571
26 CoreFoundation 0x018f5d86 __CFRunLoopRun + 470
27 CoreFoundation 0x018f5840 CFRunLoopRunSpecific + 208
28 CoreFoundation 0x018f5761 CFRunLoopRunInMode + 97
29 GraphicsServices 0x01db11c4 GSEventRunModal + 217
30 GraphicsServices 0x01db1289 GSEventRun + 115
31 UIKit 0x008c5c93 UIApplicationMain + 1160
32 <app_name> 0x00002a30 main + 192
33 <app_name> 0x00002255 start + 53
)
terminate called throwing an exception
How can I find out the reason why the app is terminated by this log and solve it? Thank you.
Note: Edit 1 and Edit 2 were removed.
Edit 3: This implemented code of tableView:numberOfRowsInSection: method works for me:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
if (filteredSectionListOfAddressBook && filteredSectionListOfAddressBook.count)
{
return [[filteredSectionListOfAddressBook objectAtIndex:section] count];
}
else
{
return 0;
}
}
else if (tableView == self.tableView)
{
if (sectionListOfAddressBook && sectionListOfAddressBook.count)
{
return [[sectionListOfAddressBook objectAtIndex:section] count];
}
else
{
return 0;
}
}
return 0;
}
In your stack trace - there is a tableview - you need to ensure that there is data to populate the table. Thats where this error is coming from
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array
You could for the moment ensure there is no data by making sure that
tableView:numberOfRowsInSection: returns 0;
Have you implemented the TableViews delegate methods?
Read about it here About Table Views in iOS-Based Applications
here UITableViewDataSource Protocol Reference
and here UITableViewDelegate Protocol Reference
I just ran into a problem like this in my code, and I found that it was caused by the search delegate holding on to the search bar and the table ref. If a set these properties to nil in searchDisplayControllerDidEndSearch then it got rid of the problem. It was likely caused by a circular ref loop. The stack trace looked like so:
[__NSArrayM _updateNoSearchResultsMessageVisiblity]: unrecognized selector sent to instance 0x21c350
#0 0x3369a1c8 in objc_exception_throw ()
#1 0x338b5aca in -[NSObject doesNotRecognizeSelector:] ()
#2 0x338b4944 in __forwarding__ ()
#3 0x3380f680 in _forwarding_prep_0__ ()
#4 0x30e5aff8 in -[UISearchResultsTableView _numberOfRowsDidChange] ()
#5 0x30d6c3b2 in -[UITableView noteNumberOfRowsChanged] ()
#6 0x30d6bf4e in -[UITableView reloadData] ()

Resources