I perform a transition between views with an animation. It sometimes works, and it also sometimes causes a crash and I don't understand why. I have my code within a #try-#catch block but no exception is retrieved in #catch. I simply get an app crash with a SIGABRT signal and the following log:
2015-09-23 10:03:43.420 My App[1510:528283] The view hierarchy is not prepared for the constraint:
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2015-09-23 10:03:43.421 My App[1510:528283] *** Assertion failure in -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/NSLayoutConstraint_UIKitAdditions.m:590
I don't understand why it sometimes works and other times it crashes, and I don't understand how can I debug this, please I need help.
Thanks in advance
EDIT:
This is the method that seems to cause the app crashes:
- (void)switchToMainView
{
[UIView transitionWithView:self.view
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
#try {
if ([self.secView superview]) {
[self setMainView];
[self.secView removeFromSuperview];
[self.view addSubview:self.mainView];
[self.view sendSubviewToBack:self.secView];
}
}
#catch (NSException *exception) {
NSLog(#"exception: %#", exception.description);
}
}
completion:^(BOOL finished){
if (finished) {
#try {
[self.view setNeedsUpdateConstraints];
[self setMessage];
}
#catch (NSException *exception) {
NSLog(#"exception: %#", exception.description);
}
}
}];
}
And the setMessage method that is called in the completion block:
- (void)setMessage
{
UIView *messageView = nil;
#try {
messageView = [[[NSBundle mainBundle] loadNibNamed:#"MessageView" owner:nil options:nil] firstObject];
messageView.frame = CGRectMake(0, 0, self.messagesContainerView.frame.size.width, self.messagesContainerView.frame.size.height);
[self.messagesContainerView.subviews makeObjectsPerformSelector: #selector(removeFromSuperview)];
[self.messagesContainerView addSubview:messageView];
}
#catch (NSException *exception) {
NSLog(#"exception: %#", exception.description);
}
}
where self.messagesContainerView is a subview of self.mainView in the first method.
Thanks again
EDIT 2:
This is the last crash information I managed to get:
Date/Time: 2015-09-24 10:01:13 +0000 OS Version: iPhone OS
9.0 (13A344) Report Version: 104
Exception Type: SIGABRT Exception Codes: #0 at 0x34de0d24 Crashed
Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up
layout with view hierarchy unprepared for constraint.'
Last Exception Backtrace: 0 CoreFoundation
0x22ee786b 0x22df2000 + 1005675 1 libobjc.A.dylib
0x345e6dff 0x345e0000 + 28159 2 CoreFoundation
0x22ee7741 0x22df2000 + 1005377 3 Foundation
0x23c772ab 0x23be0000 + 619179 4 UIKit
0x277ced17 0x26fe7000 + 8289559 5 UIKit
0x270f8b1b 0x26fe7000 + 1121051 6 UIKit
0x270f898d 0x26fe7000 + 1120653 7 UIKit
0x270f88a7 0x26fe7000 + 1120423 8 UIKit
0x277cee6d 0x26fe7000 + 8289901 9 UIKit
0x270f878f 0x26fe7000 + 1120143 10 My App
0x000423c5 0x11000 + 201669 11 UIKit
0x277d479d 0x26fe7000 + 8312733 12 Foundation
0x23c29c81 0x23be0000 + 302209 13 UIKit
0x270fbaa9 0x26fe7000 + 1133225 14 UIKit
0x277d49d9 0x26fe7000 + 8313305 15 UIKit
0x270fc78b 0x26fe7000 + 1136523 16 Foundation
0x23c29c81 0x23be0000 + 302209 17 UIKit
0x270fbaa9 0x26fe7000 + 1133225 18 UIKit
0x270fc487 0x26fe7000 + 1135751 19 UIKit
0x277d4fa5 0x26fe7000 + 8314789 20 UIKit
0x272edfa9 0x26fe7000 + 3174313 21 UIKit
0x26ff56bb 0x26fe7000 + 59067 22 QuartzCore
0x268c167d 0x268b4000 + 54909 23 QuartzCore
0x268bcd79 0x268b4000 + 36217 24 QuartzCore
0x268bcc09 0x268b4000 + 35849 25 QuartzCore
0x268bc129 0x268b4000 + 33065 26 QuartzCore
0x268bbdeb 0x268b4000 + 32235 27 QuartzCore
0x268b55bf 0x268b4000 + 5567 28 CoreFoundation
0x22eaa0f1 0x22df2000 + 753905 29 CoreFoundation
0x22ea83e7 0x22df2000 + 746471 30 CoreFoundation
0x22ea8825 0x22df2000 + 747557 31 CoreFoundation
0x22dfb1e9 0x22df2000 + 37353 32 CoreFoundation
0x22dfafdd 0x22df2000 + 36829 33 GraphicsServices
0x2c09faf9 0x2c096000 + 39673 34 UIKit
0x2706018d 0x26fe7000 + 496013 35 My App
0x000d7d69 0x11000 + 814441 36 libdyld.dylib
0x34d11873 0x34d0f000 + 10355
Thread 0 Crashed: 0 libsystem_kernel.dylib 0x34de0d24
0x34dcc000 + 85284 1 libsystem_c.dylib 0x34d78f51
0x34d2e000 + 307025 2 My App 0x001abebf
0x11000 + 1683135 3 CoreFoundation 0x22ee7ba9
0x22df2000 + 1006505 4 libobjc.A.dylib
0x345e7087 0x345e0000 + 28807 5 libc++abi.dylib
0x33dcce17 0x33db6000 + 93719 6 libc++abi.dylib
0x33dcc8f7 0x33db6000 + 92407 7 libobjc.A.dylib
0x345e6f47 0x345e0000 + 28487 8 CoreFoundation
0x22dfb26f 0x22df2000 + 37487 9 CoreFoundation
0x22dfafdd 0x22df2000 + 36829 10 GraphicsServices
0x2c09faf9 0x2c096000 + 39673 11 UIKit
0x2706018d 0x26fe7000 + 496013 12 My App
0x000d7d69 0x11000 + 814441 13 libdyld.dylib
0x34d11873 0x34d0f000 + 10355
Without seeing your code It's hard to debug the actual problem. The probably causes are:
You are adding a constraint to a view that is not a superview of the constrained class.
You are adding a constraint to a view that has not been added as a subview yet - and so is not in the view hierarchy.
As to fixing it. I managed to create a project which crashes in this way, and correctly found the mistake by adding a symbolic breakpoint as the error suggests:
So try this and see where your problem is coming from.
Related
In order to detect the behavior of refresh UI on background thread,I used the third-part library ODUIThreadGuard.
This lib is based on hook UIView's setNeedsLayout、setNeedsDisplay、setNeedsDisplayInRect selector.
When I tested it, I found that UILabel's setFrame: on background thread can be detected but UIView's can't.Who can tell me why?
code:
// ViewController.m
[self.view addSubview:self.testLabel];
[self.view addSubview:self.testView];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
self.testLabel.frame = CGRectMake(20, 20, 100, 100);
});
The above code will be detected but the following will not .
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
self.testView.frame = CGRectMake(20, 20, 100, 100);
});
hook code :
#implementation UIView (ThreadSafeGuard)
+ (void)load {
[DBHookUtil swizzlingInClass:[self class] originalSelector:#selector(setNeedsLayout) swizzledSelector:#selector(db_setNeedsLayout)];
[DBHookUtil swizzlingInClass:[self class] originalSelector:#selector(setNeedsDisplay) swizzledSelector:#selector(db_setNeedsDisplay)];
[DBHookUtil swizzlingInClass:[self class] originalSelector:#selector(setNeedsDisplayInRect:) swizzledSelector:#selector(db_setNeedsDisplayInRect:)];
}
- (void)db_setNeedsLayout {
NSAssert([NSThread isMainThread], #"refresh UI on background thread");
[self db_setNeedsLayout];
}
- (void)db_setNeedsDisplay {
NSAssert([NSThread isMainThread], #"refresh UI on background thread");
[self db_setNeedsDisplay];
}
- (void)db_setNeedsDisplayInRect:(CGRect)rect {
NSAssert([NSThread isMainThread], #"refresh UI on background thread");
[self db_setNeedsDisplayInRect:rect];
}
#end
crash log:
2017-05-15 18:17:40.876 ThreadSafeGuardDemo[50800:19659410] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'refresh UI on background thread'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105181b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000104be6141 objc_exception_throw + 48
2 CoreFoundation 0x0000000105185cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001047803b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 ThreadSafeGuardDemo 0x0000000104615068 -[UIView(ThreadSafeGuard) db_setNeedsDisplay] + 264
5 UIKit 0x00000001058311f6 -[UILabel setNeedsDisplay] + 55
6 UIKit 0x00000001058279e6 -[UILabel _invalidateAsNeededForNewSize:oldSize:withLinkCheck:] + 336
7 UIKit 0x0000000105827c9f -[UILabel setFrame:] + 76
8 ThreadSafeGuardDemo 0x0000000104614a76 __29-[ViewController viewDidLoad]_block_invoke + 278
9 libdispatch.dylib 0x0000000107f744a6 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x0000000107f9d05c _dispatch_client_callout + 8
11 libdispatch.dylib 0x0000000107f7f198 _dispatch_root_queue_drain + 1358
12 libdispatch.dylib 0x0000000107f7ebef _dispatch_worker_thread3 + 123
13 libsystem_pthread.dylib 0x00000001083c3746 _pthread_wqthread + 1299
14 libsystem_pthread.dylib 0x00000001083c3221 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
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
Team,
I got a crash when I perform below actions in my simulator,
> Navigated to Screen1 - > Screen2- > Screen3 -> Screen2 -> screen1
> Press home screen - Go to iPhone Settings screen -> Relaunch my application
> then perform the same steps (Screen1 - > Screen2- > Screen3 -> Screen2 -> screen1)
> perform the same steps Screen1 -> screen2 -> Screen3 -> CRASH on [super viewDidLoad]
I don't see any crash logs or console logs for the crash, but my debugger stops at this point.
Any idea why my application crashes only when I minimized and relaunch the application. If I don't minimize the application, everything works as expected.
Why I am not able to view any console logs for the crash?
Note: We tested on iOS6 device and there is no crash, this is observed only in iOS7 device. I can reproduce the crash only when I minimize the application, else it works fine.
seen this log only once,
2014-04-16 11:42:05.073 ADTCommercial[36614:60b] -[CALayerArray leading]: unrecognized selector sent to instance 0xac1a690
2014-04-16 11:42:05:077 ADTCommercial[36614:60b]
*÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷*
* An Exception Has Been Handled! *
Method:
-[ADT_TaskHomeList(Custom) tableView:didSelectRowAtIndexPath:] -
Exception Name:
NSInvalidArgumentException
Exception Reason:
-[CALayerArray leading]: unrecognized selector sent to instance 0xac1a690
StackTrace:
0 CoreFoundation 0x031af1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x03d7e8e5 objc_exception_throw + 44
2 CoreFoundation 0x0324c243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0319f50b ___forwarding___ + 1019
4 CoreFoundation 0x0319f0ee _CF_forwarding_prep_0 + 14
5 ADTCommercial 0x005aa1d1 +[AMPListScreenTableViewCell getHeightForFont:numberOfLines:] + 113
6 ADTCommercial 0x0059dd80 -[AMPGeneratedListViewController invalidate] + 224
7 ADTCommercial 0x0059e4f8 -[AMPGeneratedListViewController setNumberOfLines:] + 360
8 ADTCommercial 0x0059d28e -[AMPGeneratedListViewController viewDidLoad] + 270
9 ADTCommercial 0x00107208 -[ADT_SystemDetails(Custom) viewDidLoad] + 72
10 UIKit 0x02122e10 -[UIViewController awakeFromNib] + 110
11 UIKit 0x022bbf67 -[UINib instantiateWithOwner:options:] + 1955
12 UIKit 0x022bdada -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
13 ADTCommercial 0x005c1f7b -[AMPViewManager loadView] + 811
14 ADTCommercial 0x005b6916 -[AMPScreenManager showScreen:withRow:createScreen:reloadPolicy:doReset:isModal:animated:navigationController:] + 3542
15 ADTCommercial 0x0058b1ec +[AMPStandardActions gotoAction:reloadPolicy:transactionStateChange:addToHistory:] + 252
16 ADTCommercial 0x002c4935 -[ADT_TaskHomeList(Custom) tableView:didSelectRowAtIndexPath:] + 901
17 UIKit 0x020f09a1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
18 UIKit 0x020f0b14 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
19 UIKit 0x020f510e __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
20 UIKit 0x020240aa ___afterCACommitHandler_block_invoke + 15
21 UIKit 0x02024055 _applyBlockToCFArrayCopiedToStack + 403
22 UIKit 0x02023e76 _afterCACommitHandler + 532
23 CoreFoundation 0x0317736e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
24 CoreFoundation 0x031772bf __CFRunLoopDoObservers + 399
25 CoreFoundation 0x03155254 __CFRunLoopRun + 1076
26 CoreFoundation 0x031549d3 CFRunLoopRunSpecific + 467
27 CoreFoundation 0x031547eb CFRunLoopRunInMode + 123
28 GraphicsServices 0x04e805ee GSEventRunModal + 192
29 GraphicsServices 0x04e8042b GSEventRun + 104
30 UIKit 0x02006f9b UIApplicationMain + 1225
31 ADTCommercial 0x0000642e main + 126
32 libdyld.dylib 0x044c4701 start + 1
33 ??? 0x00000001 0x0 + 1
*÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷*
-(void)tableView:(UITableView *)table didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
PMPCAccountInfoTabScreen *accountsInfoTabScreen = nil;
PMPCJobWrapUp *wrapUpScreen = nil;
NSString *screenPushedUnderJobWrapUp = #"SCREEN_PUSHED_UNDER_WRAP_UP";
#try {
switch (indexPath.row) {
case 0:
// PUSH THE ACCOUNT INFORMATION SCREEN
accountsInfoTabScreen = (PMPCAccountInfoTabScreen*)[[[PMPCScreenManager sharedScreenManager] getScreen:#"PMPCAccountInfoTabScreen"] view];
[accountsInfoTabScreen setSelectedTab:0];
[PMPCStandardActions gotoAction:#"PMPCAccountInfoTabScreen" reloadPolicy:PMPCScreenReloadAlways transactionStateChange:PMPCTransactionContinue addToHistory:YES];
[Commons setClipboardValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:NO]];
break;
case 1:
// PUSH THE JOB DETAILS SCREEN
[PMPCStandardActions gotoAction:#"JobDetailsScreen" reloadPolicy:PMPCScreenReloadAlways transactionStateChange:PMPCTransactionContinue addToHistory:YES];
[Commons setClipboardValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:NO]];
break;
case 2:
//[[PMPCDataClipboard sharedClipboard] setValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:NO]];
[[PMPCDataClipboard sharedClipboard] removeValueForKey:screenPushedUnderJobWrapUp];
[Commons setClipboardValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:NO]];
[PMPCStandardActions gotoAction:#"PMPCSystemDetails" reloadPolicy:PMPCScreenReloadAlways transactionStateChange:PMPCTransactionContinue addToHistory:YES];
break;
case 3:
// Add Items screen
[Commons setClipboardValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:NO]];
[PMPCStandardActions gotoAction:#"PMPCAddedItemsList" reloadPolicy:PMPCScreenReloadAlways transactionStateChange:PMPCTransactionContinue addToHistory:YES];
break;
case 4:
// PUSH THE JOB WRAP UP SCREEN
//JobWrapUpObject *wrapUp = [Commons getJobWrapUpObject];
//[wrapUp resetValues];
wrapUpScreen = (PMPCJobWrapUp*)[[[PMPCScreenManager sharedScreenManager] getScreen:#"PMPCJobWrapUp"] view];
[wrapUpScreen setScrollToTop:YES];
[Commons setClipboardValueForKey:screenPushedUnderJobWrapUp value:[NSNumber numberWithBool:YES]];
[PMPCStandardActions gotoAction:#"PMPCJobWrapUp" reloadPolicy:PMPCScreenReloadAlways transactionStateChange:PMPCTransactionBegin addToHistory:YES];
break;
default:
break;
}
}
#catch (NSException *exception) {
ExceptionLog(exception);
}
#finally {
[PMPCLog trace:#"%s Ends",__PRETTY_FUNCTION__];
}
}
Thanks,
Ramesh
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
I'm getting a strange crash with the iAd error callback. Here is my crash log:
Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0x2281
0com.apple.main-thread Crashed
0 libobjc.A.dylib objc_retain + 17
1 YouDoodle AdView.m line 265 -[AdContainerView requestGAD]
2 iAd -[ADBannerView _forwardErrorToDelegate:] + 254
3 iAd -[ADBannerView serverBannerViewDidFailToReceiveAdWithError:] + 178
4 iAd -[ADAdSpace setServiceAdSpace:] + 472
5 CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6 CoreFoundation _CFXNotificationPost + 1718
7 Foundation -[NSNotificationCenter postNotificationName:object:userInfo:] + 76
8 Foundation -[NSNotificationCenter postNotificationName:object:] + 30
9 iAd -[ADAdSheetProxy _adSheetConnectionLost] + 292
10 ... libdispatch.dylib _dispatch_call_block_and_release + 10
11 libdispatch.dylib _dispatch_client_callout + 22
12 libdispatch.dylib _dispatch_main_queue_callback_4CF$VARIANT$up + 274
13 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
14 CoreFoundation __CFRunLoopRun + 1300
15 CoreFoundation CFRunLoopRunSpecific + 522
16 CoreFoundation CFRunLoopRunInMode + 106
17 GraphicsServices GSEventRunModal + 138
18 UIKit UIApplicationMain + 1136
19 YouDoodle
AppDelegate.m line 129
main
http://crashes.to/s/c654d14dcfa
delegate callback for iAd:
- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
DLog(#"IAD Failed to load with error %#", error);
self.adBannerContainer.hidden = YES;
if (InternetAvailableWithAlert(NO))
{
if (self.gadAvailable)
{
self.gadBannerContainer.hidden = NO;
}
else
{
[self requestGAD];
}
}
}
- (void) requestGAD
{
GADRequest* request = [[GADRequest alloc] init];
#if TARGET_IPHONE_SIMULATOR
request.testDevices = #[GAD_SIMULATOR_ID];
#endif
self.gadBanner.rootViewController = (self.gadBanner.rootViewController ?: self.viewController);
[self.gadBanner loadRequest:request];
}
The iAd view delegate is a singleton which is never released. Even if it was released, the iAd class delegate property is a weak property so it should auto-nil.
#property (nonatomic, weak) id<ADBannerViewDelegate> delegate;
Ideas?
This was due to setting the Admob SDK root view controller back to itself, when the view controller has been deallocated, this crashes. Admob SDK uses an assign reference instead of weak which is why it crashed.