iPhone app crashes with exception - iphone

I have an iPhone app which uses iAd...The app crashes sometime with the following message;
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x621cd10'
*** Call stack at first throw:
(
0 CoreFoundation 0x00e015a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f55313 objc_exception_throw + 44
2 CoreFoundation 0x00e030bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d72966 ___forwarding___ + 966
4 CoreFoundation 0x00d72522 _CF_forwarding_prep_0 + 50
5 CoreFoundation 0x00d71c7d __invoking___ + 29
6 CoreFoundation 0x00d71b51 -[NSInvocation invoke] + 145
7 CoreFoundation 0x00d72a04 ___forwarding___ + 1124
8 CoreFoundation 0x00d72522 _CF_forwarding_prep_0 + 50
9 iAd 0x00[Switching to process 8860 thread 0x207]
0139f9 -[ADDistributedMessagingCenter messagePort:receivedMessage:withData:] + 251
10 iAd 0x00014012 ADMessagePortCallBack + 75
11 CoreFoundation 0x00db8f4c __CFMessagePortPerform + 396
12 CoreFoundation 0x00de2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x00d42cf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x00d3ff83 __CFRunLoopRun + 979
15 CoreFoundation 0x00d3f840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x00d3f761 CFRunLoopRunInMode + 97
17 GraphicsServices 0x033fe1c4 GSEventRunModal + 217
18 GraphicsServices 0x033fe289 GSEventRun + 115
19 UIKit 0x002ffc93 UIApplicationMain + 1160
20 MyApp 0x00001ba8 main + 102
21 MyApp 0x00001b39 start + 53
)
terminate called after throwing an instance of 'NSException'
Below is my NSZombie message;
# Category Event Type RefCt Timestamp Address Size Responsible Library Responsible Caller
77 DetailController Zombie -1 04:01.914.883 0x5768bd0 0 iAd -[ADDistributedMessagingCenter messagePort:receivedMessage:withData:]
Also bannerViewDidLoadAd code;
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
// assumes the banner view is offset -50 pixels so that it is not visible.
banner.frame = CGRectOffset(banner.frame, 0, -50); // if the banner is on top of the screen use 50
[UIView commitAnimations];
bannerIsVisible = YES;
}
}
Please help me fix the same. Thank you.

Basically you're calling bannerViewDidLoadAd: with the wrong object type. It appears that you're using some sort of dispatch mechanism to do this. Either you specified the wrong object when you set up the dispatch request for that method, or you failed to retain the object and it's been deleted and replaced with a NSType object.
So find where bannerViewDidLoadAd: is mentioned in your code and make sure the object being used with it is correct and is appropriately retained.

bannerViewDidLoad is getting called after it's delegate is released, hence the zombie message.
I would guess that this means your ad isn't being released and is sticking around after your controller is going away.

Related

getting error when presenting view controller

i am getting this error when trying to presenting view controller. actuallly i am testing this project on ios 4.3 simulator.on other simuators it works fine. this is non arc project. which is supported for ios 4.3 and onward.
request on uploadmanager:<NSMutableURLRequest http://www.livebinders.com/filetree/ipad>
2013-10-12 14:00:54.690 LiveBinders[1703:13b03] -[UploadManagerViewController presentViewController:animated:]: unrecognized selector sent to instance 0x6605a30
2013-10-12 14:00:54.695 LiveBinders[1703:13b03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UploadManagerViewController presentViewController:animated:]: unrecognized selector sent to instance 0x6605a30'
*** Call stack at first throw:
(
0 CoreFoundation 0x01ca85a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x017bc313 objc_exception_throw + 44
2 CoreFoundation 0x01caa0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01c19966 ___forwarding___ + 966
4 CoreFoundation 0x01c19522 _CF_forwarding_prep_0 + 50
5 LiveBinders 0x0003baa8 -[UploadManagerViewController openEvernote] + 248
6 LiveBinders 0x00068e4b -[TableVC tableView:didSelectRowAtIndexPath:] + 171
7 UIKit 0x00b97b68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
8 UIKit 0x00b8db05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
9 Foundation 0x012a779e __NSFireDelayedPerform + 441
10 CoreFoundation 0x01c898c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
11 CoreFoundation 0x01c8ae74 __CFRunLoopDoTimer + 1220
12 CoreFoundation 0x01be72c9 __CFRunLoopRun + 1817
13 CoreFoundation 0x01be6840 CFRunLoopRunSpecific + 208
14 CoreFoundation 0x01be6761 CFRunLoopRunInMode + 97
15 GraphicsServices 0x01dfc1c4 GSEventRunModal + 217
16 GraphicsServices 0x01dfc289 GSEventRun + 115
17 UIKit 0x00b2ec93 UIApplicationMain + 1160
18 LiveBinders 0x0000285d main + 93
19 LiveBinders 0x000027b5 start + 53
<----- calling this method on presenting new view controller ---->
-(void)openEvernote
{
self.dropboxShareLink = NULL;
self.dropBoxFileName = NULL;
EverNoteVC *everNoteVC = [[EverNoteVC alloc]initWithNibName:#"EverNoteView" bundle:nil];
everNoteVC.delegate = (id)self;
if (popoverController.isPopoverVisible) {
[popoverController dismissPopoverAnimated:NO];
}
[self presentViewController:everNoteVC animated:YES ];
[everNoteVC release];
}
presentViewController is not available in iOS versions prior 5.0.
Try with
[self presentModalViewController:everNoteVC animated:YES];
instead.

Error in dismissing a modal view controller

I have encountered application termination while dismissing a modal view controller.
-[NSCFString window]: unrecognized selector sent to instance 0x6337dc0
2011-06-03 13:26:37.980 Tuscany[19657:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString window]: unrecognized selector sent to instance 0x6337dc0'
*** Call stack at first throw:
(
0 CoreFoundation 0x016ffbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018545c2 objc_exception_throw + 47
2 CoreFoundation 0x017016fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01671366 ___forwarding___ + 966
4 CoreFoundation 0x01670f22 _CF_forwarding_prep_0 + 50
5 UIKit 0x003f4024 -[UIViewController viewControllerForRotation] + 81
6 UIKit 0x003ee8ab -[UIViewController shouldWindowUseOnePartInterfaceRotationAnimation:] + 34
7 UIKit 0x00368dd5 -[UIWindow _clientsForRotation] + 350
8 UIKit 0x0036b87b -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 141
9 UIKit 0x005eb948 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1053
10 UIKit 0x003f7682 -[UIViewController _dismissModalViewControllerWithTransition:from:] + 2075
11 UIKit 0x003f4324 -[UIViewController dismissModalViewControllerWithTransition:] + 579
12 Foundation 0x000c37f6 __NSFireDelayedPerform + 441
13 CoreFoundation 0x016e0fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
14 CoreFoundation 0x016e2594 __CFRunLoopDoTimer + 1220
15 CoreFoundation 0x0163ecc9 __CFRunLoopRun + 1817
16 CoreFoundation 0x0163e240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x0163e161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x01d88268 GSEventRunModal + 217
19 GraphicsServices 0x01d8832d GSEventRun + 115
20 UIKit 0x0035342e UIApplicationMain + 1160
21 Tuscany 0x00002878 main + 102
22 Tuscany 0x00002809 start + 53
)
terminate called after throwing an instance of 'NSException'
Above is the crash log. Please help.
Thanks in advance.
From you log it seems that you are calling window on an NSCFString. NSCFString does not have a window selector, and the compiler would complain if you try and do so, so it is likely that you are sending that message to a deallocated object (imagine that a new object has been allocated where another one was previously), or you are messing with casts.
In case you suspect that you are sending the message to a deallocated object, enable NSZombies.
Without seeing the code, it is not possible to help you further, though.

iOS: Displaying a new modal view on top of master (root) view in split view

I need to call a new modal view in the master view area after selecting a specific object from the initial list (tableview).
Tried this:
//new view init:
clientList *clientListCon = [[clientList alloc] initWithNibName:#"clientList" bundle:nil];
//pushing
[[splitViewController.viewControllers objectAtIndex:0] presentModalViewController:clientListCon animated:YES];
All I get:
MultipleDetailViews[12997:40b] -[UITableView presentModalViewController:animated:]: unrecognized selector sent to instance 0x584d800
2011-03-18 14:40:51.449 MultipleDetailViews[12997:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView presentModalViewController:animated:]: unrecognized selector sent to instance 0x584d800'
*** Call stack at first throw:
(
0 CoreFoundation 0x017035a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01857313 objc_exception_throw + 44
2 CoreFoundation 0x017050bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01674966 ___forwarding___ + 966
4 CoreFoundation 0x01674522 _CF_forwarding_prep_0 + 50
5 MultipleDetailViews 0x00008051 -[RootViewController tableView:didSelectRowAtIndexPath:] + 354
6 UIKit 0x00a8fb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
7 UIKit 0x00a85b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
8 Foundation 0x0079779e __NSFireDelayedPerform + 441
9 CoreFoundation 0x016e48c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
10 CoreFoundation 0x016e5e74 __CFRunLoopDoTimer + 1220
11 CoreFoundation 0x016422c9 __CFRunLoopRun + 1817
12 CoreFoundation 0x01641840 CFRunLoopRunSpecific + 208
13 CoreFoundation 0x01641761 CFRunLoopRunInMode + 97
14 GraphicsServices 0x0205a1c4 GSEventRunModal + 217
15 GraphicsServices 0x0205a289 GSEventRun + 115
16 UIKit 0x00a26c93 UIApplicationMain + 1160
17 MultipleDetailViews 0x000069a4 main + 102
18 MultipleDetailViews 0x00006935 start + 53
)
terminate called after throwing an instance of 'NSException'
It seems like it ought to be:
[self presentModalViewController:clientListCon animated:YES];
I have no idea how you are getting a reference to a UITableView from the provided code though.

Terminating app due to uncaught exception 'NSInvalidArgumentException'

I am using ShareKit to allow the user to share their score on Twitter and Facebook in my iPhone app. However, it seems to crash shortly after sharing on either service. I get an console message which says:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString rangeOfString:options:range:locale:]: nil argument'
*** Call stack at first throw:
(
0 CoreFoundation 0x026d6919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x028245de objc_exception_throw + 47
2 CoreFoundation 0x0268f078 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0268efea +[NSException raise:format:] + 58
4 Foundation 0x0008f97b -[NSString rangeOfString:options:range:locale:] + 424
5 Foundation 0x0009de16 -[NSString rangeOfString:] + 104
6 iPhone Typer 0x00030220 -[SHKOAuthView webView:shouldStartLoadWithRequest:navigationType:] + 151
7 UIKit 0x004bb456 -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:] + 458
8 CoreFoundation 0x0264742d __invoking___ + 29
9 CoreFoundation 0x02647301 -[NSInvocation invoke] + 145
10 WebCore 0x030940f0 _ZL20HandleDelegateSourcePv + 64
11 CoreFoundation 0x026b7d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
12 CoreFoundation 0x026162cb __CFRunLoopDoSources0 + 571
13 CoreFoundation 0x026157c6 __CFRunLoopRun + 470
14 CoreFoundation 0x02615280 CFRunLoopRunSpecific + 208
15 CoreFoundation 0x026151a1 CFRunLoopRunInMode + 97
16 GraphicsServices 0x02e5e2c8 GSEventRunModal + 217
17 GraphicsServices 0x02e5e38d GSEventRun + 115
18 UIKit 0x00339b58 UIApplicationMain + 1160
19 iPhone Typer 0x00002894 main + 102
20 iPhone Typer 0x00002825 start + 53
)
terminate called after throwing an instance of 'NSException'
How would I fix this? Thanks.
Set a breakpoint on objc_exception_throw, then build the app for debug, run the app with breakpoints on and cause the crash again, then go up the stack to the relevant code.
Something inside SHKOAuthView webView:shouldStartLoadWithRequest:navigationType: is passing a nil argument to NSString rangeOfString. When you know what is passing the nil, it may be obvious what the problem is - failing that update your question with the relevant code and any extra information you've determined.

What is the possible reason of "[UIWindow length]: unrecognized selector" error

My iPhone app is a Tab Bar Application, which has 5 tabs. In each tab, there is a table view, embedded with navigation controller. When these table views appear, data will be loaded from database.
When I switch the tabs very fast by tapping the tab bar randomly, the app crashes sometimes.
The error is:
+[UIWindow length]: unrecognized selector sent to class 0x3e055bd4
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIWindow length]: unrecognized selector sent to class 0x3e055bd4'
terminate called after throwing an instance of 'NSException'
Does anyone have advices or hints about find out the reason of the problem?
P.S. I created another similar but simpler app, which cannot be crashed by this way.
More info about calling stack:
> *** Call stack at first throw:
(
0 CoreFoundation 0x31785fd3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x320118a5 objc_exception_throw + 24
2 CoreFoundation 0x31789af3 +[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x31788f15 ___forwarding___ + 508
4 CoreFoundation 0x3171b680 _CF_forwarding_prep_0 + 48
5 UIKit 0x3019a3ff -[UITableHeaderFooterView setText:] + 30
6 UIKit 0x3028239d -[UITableView(UITableViewInternal) _sectionHeaderView:withFrame:forSection:opaque:reuseViewIfPossible:] + 488
7 UIKit 0x30199e41 -[UITableView(UITableViewInternal) _sectionHeaderViewWithFrame:forSection:opaque:reuseViewIfPossible:] + 60
8 UIKit 0x3016bcb1 -[UITableView(_UITableViewPrivate) _updateVisibleHeadersAndFootersNow:] + 852
9 UIKit 0x3016b1a1 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1408
10 UIKit 0x301693c1 -[UITableView layoutSubviews] + 140
11 UIKit 0x301276ab -[UIView(CALayerDelegate) _layoutSublayersOfLayer:] + 26
12 CoreFoundation 0x317117ff -[NSObject(NSObject) performSelector:withObject:] + 22
13 QuartzCore 0x321e2585 -[CALayer layoutSublayers] + 120
14 QuartzCore 0x321e233d CALayerLayoutIfNeeded + 184
15 QuartzCore 0x321e1e0f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 210
16 QuartzCore 0x321e1b69 _ZN2CA11Transaction6commitEv + 192
17 QuartzCore 0x321e740d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 52
18 CoreFoundation 0x3175ba49 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
19 CoreFoundation 0x3175d475 __CFRunLoopDoObservers + 412
20 CoreFoundation 0x3175e77b __CFRunLoopRun + 854
21 CoreFoundation 0x317078eb CFRunLoopRunSpecific + 230
22 CoreFoundation 0x317077f3 CFRunLoopRunInMode + 58
23 GraphicsServices 0x33ac26ef GSEventRunModal + 114
24 GraphicsServices 0x33ac279b GSEventRun + 62
25 UIKit 0x3011e2a7 -[UIApplication _run] + 402
26 UIKit 0x3011ce17 UIApplicationMain + 670
27 MyAPP 0x00002193 main + 70
28 MyAPP 0x00002114 start + 52
)
Most likely a dangling pointer to a former NSString now occupied by a UIWindow object. You'll have to find the lost object and probably retain it.
In XCode, select "Edit Active Executable..." under the Project menu. Select the "Arguments" tab and add an entry named "NSZombieEnabled" set to "YES" to the "Variables to be set in the environment" section.
NSZombieEnabled marks deleted objects as "Zombies" rather than reclaiming their space. When enabled, an exception is thrown any time a message is sent to a Zombie object. That should help you narrow down which object is not being retained properly.
Happy Zombie Hunting!
I can only guess that you try to call +[UIWindow length] somewhere in your code. And the method length does not exist in Apple API
Eventually, I found the problem.
I init a subview in viewWillApear: and use it in tableView:viewForHeaderInSection: and release the subview in viewDidDisappear:.
I changed the init/release into viewDidLoad: and viewDidUnload:. Then the problem is gone.
Thank both answerers and hope this answer will help others.