unrecognized selector sent to instance 0xa7ac9a0 [closed] - iphone

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am making an iPad app compatible for iOS7. App is working perfect in iOS 6 but it crashes in iOS 7.
if ([self.exercise.variant isEqualToString:kVariantGFTextItem]) {
NSLog(#"item:%#",[[[itemArray objectAtIndex:0] superview]superview]);
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
itemView = (GapsFillItem*)[[[itemArray objectAtIndex:0] superview]superview];
}
[itemView.buttonPlaySound setImage:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)?kImageButtonSoundPerItemPad:kImageButtonSoundPerItemPhone forState:UIControlStateNormal];
itemView.buttonPlaySound.userInteractionEnabled = YES;
}
This code is worked perfect in iOS 6 but not in iOS 7.
Here is the crash log :
2013-10-19 09:41:53.208 Elementary[645:a0b] item:<TextViewWithTextField: 0xa9e3800; baseClass = UITextView; frame = (183 -10; 562 92); text = 'Hello. Can I +change+   ...'; clipsToBounds = YES; gestureRecognizers = <NSArray: 0xa7a8170>; layer = <CALayer: 0xa7a7ef0>; contentOffset: {0, 0}>
2013-10-19 09:41:53.209 Elementary[645:a0b] -[__NSArrayM buttonPlaySound]: unrecognized selector sent to instance 0xa7ac9a0
2013-10-19 09:41:53.212 Elementary[645:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM buttonPlaySound]: unrecognized selector sent to instance 0xa7ac9a0'
*** First throw call stack:
(
0 CoreFoundation 0x02a435e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027178b6 objc_exception_throw + 44
2 CoreFoundation 0x02ae0903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x02a3390b ___forwarding___ + 1019
4 CoreFoundation 0x02a334ee _CF_forwarding_prep_0 + 14
5 Elementary 0x00066185 -[GapsFill checkAnswers] + 4693
6 Elementary 0x00011bd4 -[ParentViewController checkToolMenuItemTapped] + 228
7 Elementary 0x0002da45 -[ToolsMenu menuItemTapped:] + 565
8 libobjc.A.dylib 0x02729874 -[NSObject performSelector:withObject:withObject:] + 77
9 UIKit 0x00f1dc8c -[UIApplication sendAction:to:from:forEvent:] + 108
10 UIKit 0x00f1dc18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
11 UIKit 0x010156d9 -[UIControl sendAction:to:forEvent:] + 66
12 UIKit 0x01015a9c -[UIControl _sendActionsForEvents:withEvent:] + 577
13 UIKit 0x01014d4b -[UIControl touchesEnded:withEvent:] + 641
14 UIKit 0x00f5b0cd -[UIWindow _sendTouchesForEvent:] + 852
15 UIKit 0x00f5bd34 -[UIWindow sendEvent:] + 1232
16 UIKit 0x00f2fa36 -[UIApplication sendEvent:] + 242
17 UIKit 0x00f19d9f _UIApplicationHandleEventQueue + 11421
18 CoreFoundation 0x029cc8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
19 CoreFoundation 0x029cc23b __CFRunLoopDoSources0 + 235
20 CoreFoundation 0x029e930e __CFRunLoopRun + 910
21 CoreFoundation 0x029e8b33 CFRunLoopRunSpecific + 467
22 CoreFoundation 0x029e894b CFRunLoopRunInMode + 123
23 GraphicsServices 0x035b79d7 GSEventRunModal + 192
24 GraphicsServices 0x035b77fe GSEventRun + 104
25 UIKit 0x00f1c94b UIApplicationMain + 1225
26 Elementary 0x00002285 main + 181
27 Elementary 0x000021c5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Please if anyone has any idea why it is happening. Please let me know.

Your itemView, which it looks like you expect to be of type GapsFillItem, is actually of type NSArray.
You know this because the crash report is telling you that NSArray does not recognize the selector named buttonPlaySound, which I assume is defined on the GapsFillItem class.
I recommend throwing some NSLog statements in there to understand how itemView is becoming an NSArray.
In general, lines like this are very dubious:
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
itemView = (GapsFillItem*)[[[itemArray objectAtIndex:0] superview]superview];
One of these two lines is where the problem is. I would recommend avoiding accessing objects via calls to superview upon superview upon subviews etc etc. If you need to reach something via this sort of chain there's most likely a better way.
Best of luck
Edit
At second glance it looks like this will always crash on iPad because of this line:
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
Subviews is an array. This is your problem. You probably mean to set itemView to an item within subviews.
That said, the crash may just be device specific and have nothing to do with iOS 7.

Related

Swift ViewController textFieldCancel:]: unrecognized selector sent to instance during segue [duplicate]

This question already has answers here:
"Unrecognized selector sent to instance" error
(3 answers)
Closed 7 years ago.
I've run into an annoying issue when trying to segue to a Pages View Controller from my initial UIViewController. My initial UIViewController, among other things, includes a UITextField. Everytime I attempt to segue out of my initial UIViewController after I've used the UITextField at all, the app crashes with the error below. If I don't interact with the UITextField I seem to be able to use segues at will. From reading other posts I'm lead to believe there are some resources being used by the UITextField that I'm not properly releasing, but after trying numerous longshot attempts at fixing it, I'm left out of ideas/knowledge.
Error Message:
2015-05-22 20:10:13.961 checkdgt[7503:506991] -[checkdgt.ViewController textFieldCancel:]: unrecognized selector sent to instance 0x7f8750826e00
2015-05-22 20:10:14.033 checkdgt[7503:506991] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[checkdgt.ViewController textFieldCancel:]: unrecognized selector sent to instance 0x7f8750826e00'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bd00c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010df63bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010bd080ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010bc5e13c ___forwarding___ + 988
4 CoreFoundation 0x000000010bc5dcd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010cc5dda2 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010cd6f54a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010cd6e09a -[UIControl cancelTouchTracking] + 44
8 UIKit 0x000000010cd6eadd -[UIControl _didMoveFromWindow:toWindow:] + 89
9 UIKit 0x000000010ccd774a -[UIView(Internal) _didMoveFromWindow:toWindow:] + 698
10 UIKit 0x000000010ccd774a -[UIView(Internal) _didMoveFromWindow:toWindow:] + 698
11 UIKit 0x000000010cccfecf __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
12 UIKit 0x000000010cccfe43 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
13 UIKit 0x000000010cccdfa3 -[UIView(Hierarchy) removeFromSuperview] + 479
14 UIKit 0x000000010cd6c4dc __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke504 + 657
15 UIKit 0x000000010cd684f2 -[UIPresentationController transitionDidFinish:] + 87
16 UIKit 0x000000010d31a2ed -[_UIFullscreenPresentationController transitionDidFinish:] + 70
17 UIKit 0x000000010cd6ab7c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 133
18 UIKit 0x000000010d3a97c0 -[_UIViewControllerTransitionContext completeTransition:] + 110
19 UIKit 0x000000010cd65be3 -[UITransitionView _didCompleteTransition:] + 1120
20 UIKit 0x000000010ccbc136 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 209
21 UIKit 0x000000010ccbc46c -[UIViewAnimationState animationDidStop:finished:] + 76
22 QuartzCore 0x000000010ca43882 _ZN2CA5Layer23run_animation_callbacksEPv + 308
23 libdispatch.dylib 0x000000010e693614 _dispatch_client_callout + 8
24 libdispatch.dylib 0x000000010e67ba1c _dispatch_main_queue_callback_4CF + 1664
25 CoreFoundation 0x000000010bc681f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
26 CoreFoundation 0x000000010bc29dcb __CFRunLoopRun + 2043
27 CoreFoundation 0x000000010bc29366 CFRunLoopRunSpecific + 470
28 GraphicsServices 0x000000010f88ba3e GSEventRunModal + 161
29 UIKit 0x000000010cc5c900 UIApplicationMain + 1282
30 checkdgt 0x000000010b1f3f87 main + 135
31 libdyld.dylib 0x000000010e6c7145 start + 1
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Last bit of code before the segue is called:
#IBAction func learnButtonPressed(sender: UIButton) {
view.endEditing(true)
textInputFieldOutlet.resignFirstResponder()
textFieldShouldEndEditing(textInputFieldOutlet)
performSegueWithIdentifier("LearnPagesSegue", sender: nil)
}
I can't find any methods or objects in my code named -textFieldCancel, and the only other UITextField I can think of would be in the included CardIO library, which doesn't seem to be the suspect.
I'm using Xcode 6.3.2 and the latest version of Swift.
Any help or gentle nudges are appreciated.
Thanks!
Check that there isn't an old connection from your button by right clicking on it in the storyboard and examining the outlets in the list. You may have an old connection that you forgot to eliminate.

NSMutableString appendString generates SIGABRT Error

New here (this forum and Xcode in general), so bear with me.
I've spent multiple hours off and on over the last severals days trying to track down what exactly that I'm doing wrong here, but I just don't seem to be able to pinpoint my issue.
Here's the relevant sections of my code (I believe).
In the header:
#interface BlahViewController : UIViewController {
NSMutableString *display;
}
#property (nonatomic, retain) NSMutableString *display;
In the main:
#implementation BlahViewController
#synthesize display;
- (void)viewDidLoad {
self.display = [[NSMutableString alloc] init];
}
- (void)anotherFunction:(UIButton *)sender {
NSString *info = [[sender titleLabel] text];
[self.display appendString:info];
}
I run the code, press the UIButton, and I get an error. Here's the initial throw:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM appendString:]: unrecognized selector sent to instance 0x4e3d300' ***
Thanks!
EDIT: The whole stack trace was requested, so here it is (after reviewing the stack I realize there may be confusion, I'm writing a very basic calculator currently, so the ViewController, etc, should consider that backdrop and "anotherFunction" = "digitPressed" in this particular case):
* Call stack at first throw:
(
0 CoreFoundation 0x00e345a9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f88313 objc_exception_throw + 44
2 CoreFoundation 0x00e360bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00da5966 __forwarding + 966
4 CoreFoundation 0x00da5522 _CF_forwarding_prep_0 + 50
5 Calculator 0x0000273b -[CalculatorViewController digitPressed:] + 113
6 UIKit 0x002bb4fd -[UIApplication sendAction:to:from:forEvent:] + 119
7 UIKit 0x0034b799 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x0034dc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9 UIKit 0x0034c7d8 -[UIControl touchesEnded:withEvent:] + 458
10 UIKit 0x002dfded -[UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x002c0c37 -[UIApplication sendEvent:] + 447
12 UIKit 0x002c5f2e _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x01723992 PurpleEventCallback + 1550
14 CoreFoundation 0x00e15944 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52
15 CoreFoundation 0x00d75cf7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00d72f83 __CFRunLoopRun + 979
17 CoreFoundation 0x00d72840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00d72761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x017221c4 GSEventRunModal + 217
20 GraphicsServices 0x01722289 GSEventRun + 115
21 UIKit 0x002c9c93 UIApplicationMain + 1160
22 Calculator 0x00002254 main + 102
23 Calculator 0x000021e5 start + 53
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c
* Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'-[__NSArrayM appendString:]:
unrecognized selector sent to instance
0x4e3d300' *
This indicates that you are calling appendString: an instance of some kind of NSArray, which obviously won't work.
Assuming that [self.display appendString:info]; is the actual source of the exception, then it is happening because self.display has likely been over-released and, coincidentally, an NSArray instance was allocated at the same place in memory.
You could use zombie detection to debug this.
Alternatively, you might be corrupting memory somewhere. Or, maybe, there is another assignment to display.
In any case, whenever you have a crash, there will be a backtrace. Please post it. There is the off chance that the crash is happening somewhere else.
5 Calculator 0x0000273b -[CalculatorViewController digitPressed:] + 113
Show the source to your digitPressed: method.
self.display = [[NSMutableString alloc] init];
That is a memory leak; it'll be retained twice. Just do self.display = [NSMutableString string]; and self.display = nil; (in your viewDidUnload).
But that isn't the source of your problem; something is resetting the display variable or it is being over-released. Show all uses of display.

Assertion Failure

I am developing an iPad application with SDK4.2. I have a very strange error when touching any textField in my application. The first time I touch, the keyboard is shown, but when a second touch is done in the object I obtain following trace.
And it occurs also in any TextField shown in a HTML page with a UIWebView object.
Any ideas?
I am really confused with this.. Thanks in advance!
2010-12-17 11:53:11.697 BancoPopular[48914:207] *** Assertion failure in -[UIButtonLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UILabel.m:314
2010-12-17 11:53:11.699 BancoPopular[48914:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color'
*** Call stack at first throw:
(
0 CoreFoundation 0x01730be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018855c2 objc_exception_throw + 47
2 CoreFoundation 0x016e9628 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0013947b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0045d1dc -[UILabel setTextColor:] + 164
5 UIKit 0x0052177b -[UIButton layoutSubviews] + 1337
6 UIKit 0x005f3420 -[UICalloutBarButton layoutSubviews] + 54
7 QuartzCore 0x011a4451 -[CALayer layoutSublayers] + 181
8 QuartzCore 0x011a417c CALayerLayoutIfNeeded + 220
9 QuartzCore 0x011a4088 -[CALayer layoutIfNeeded] + 111
10 UIKit 0x0051f2ff -[UIButton titleLabel] + 81
11 UIKit 0x005f81d1 -[UICalloutBarButton setContentScale:] + 141
12 UIKit 0x005f6c5d -[UICalloutBar _updateVisibleItems] + 2240
13 UIKit 0x005f2970 -[UICalloutBar appear] + 211
14 UIKit 0x005eaaa9 -[UITextSelectionView showCommandsWithReplacements:] + 291
15 Foundation 0x000bd7f6 __NSFireDelayedPerform + 441
16 CoreFoundation 0x01711fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
17 CoreFoundation 0x01713594 __CFRunLoopDoTimer + 1220
18 CoreFoundation 0x0166fcc9 __CFRunLoopRun + 1817
19 CoreFoundation 0x0166f240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x0166f161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01e25268 GSEventRunModal + 217
22 GraphicsServices 0x01e2532d GSEventRun + 115
23 UIKit 0x0034d42e UIApplicationMain + 1160
24 BancoPopular 0x0000292e main + 84
25 BancoPopular 0x000028d1 start + 53
26 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Look carefully what exception was about. It said "reason: 'Invalid parameter not satisfying: color'", somewhere in your code, you provide wrong parameter that is supposed to be valid colors. Apparently, it seems like you use UIButton with label and set its color but not valid.
My guess is that you have some object going away somewhere, and that object contains the "color" value.
Most likely you received an autoreleased value from some call and did not retain it, so it went "poof" when the UI came up for air.

unrecognized selector sent to instance. Method being called for random objects

Ok, so this has me completely stumped just like the guy here with the exact problem.
I have a UITableView with some rows in a view controller which supports autorotation and sometimes, if i rotate the phone, i get "EXC_BAD_ACCESS" and sometimes i get SIGABRT with a stack trace like:
2010-11-19 16:51:05.634 [2306:307] -[CABasicAnimation numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x58207d0
2010-11-19 16:51:05.688 [2306:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CABasicAnimation numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x58207d0'
*** Call stack at first throw:
(
0 CoreFoundation 0x344aaed3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x33975811 objc_exception_throw + 24
2 CoreFoundation 0x344ac683 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x344541d9 ___forwarding___ + 508
4 CoreFoundation 0x34453f90 _CF_forwarding_prep_0 + 48
5 UIKit 0x31b20717 -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] + 66
6 UIKit 0x31b20677 -[UITableViewRowData invalidateAllSections] + 50
7 UIKit 0x31b2048d -[UITableView(_UITableViewPrivate) _updateRowData] + 64
8 UIKit 0x31b22941 -[UITableView(_UITableViewPrivate) _ensureRowDataIsLoaded] + 24
9 UIKit 0x31b22909 -[UITableView numberOfSections] + 16
10 UIKit 0x31bd114f -[UISearchDisplayController _updateNoSearchResultsMessageVisiblity] + 54
11 UIKit 0x31cfbef7 -[UISearchDisplayController windowWillAnimateRotation:] + 478
12 Foundation 0x3325d6b3 _nsnote_callback + 142
13 CoreFoundation 0x34431713 __CFXNotificationPost_old + 402
14 CoreFoundation 0x344313b3 _CFXNotificationPostNotification + 118
15 Foundation 0x3324cdb7 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
16 UIKit 0x31b5dbb7 -[UIWindow _setRotatableClient:toOrientation:duration:force:] + 3114
17 UIKit 0x31b64013 -[UIWindow _setRotatableViewOrientation:duration:force:] + 50
18 UIKit 0x31b39a0f -[UIWindow _updateToInterfaceOrientation:duration:force:] + 74
19 UIKit 0x31b39be9 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 112
20 UIKit 0x31b39b15 -[UIWindow _handleDeviceOrientationChange:] + 88
21 Foundation 0x3325d6b3 _nsnote_callback + 142
22 CoreFoundation 0x34431713 __CFXNotificationPost_old + 402
23 CoreFoundation 0x344313b3 _CFXNotificationPostNotification + 118
24 Foundation 0x3324cdb7 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
25 UIKit 0x31b0d0ed -[UIDevice setOrientation:animated:] + 144
26 UIKit 0x31b2a51b -[UIApplication handleEvent:withNewEvent:] + 2738
27 UIKit 0x31b29901 -[UIApplication sendEvent:] + 44
28 UIKit 0x31b29337 _UIApplicationHandleEvent + 5110
29 GraphicsServices 0x3026c04b PurpleEventCallback + 666
30 CoreFoundation 0x3443fce3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
31 CoreFoundation 0x3443fca7 __CFRunLoopDoSource1 + 166
32 CoreFoundation 0x3443256d __CFRunLoopRun + 520
33 CoreFoundation 0x34432277 CFRunLoopRunSpecific + 230
34 CoreFoundation 0x3443217f CFRunLoopRunInMode + 58
35 GraphicsServices 0x3026b5f3 GSEventRunModal + 114
36 GraphicsServices 0x3026b69f GSEventRun + 62
37 UIKit 0x31ad0123 -[UIApplication _run] + 402
38 UIKit 0x31ace12f UIApplicationMain + 670
39 App 0x0000285f main + 70
40 App 0x00002814 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
In this case it is CABasicAnimation on which numberOfSectionsInTableView is being called but sometimes there are class names like NSMachPort which i have never heard of. Also, the method being called numberOfSectionsInTableView remains the same with the class names changing to always give a doesNotRecognizeSelector exception.
Also this problem only happens when i try to rotate the device. Whenever i get a stack trace like above, there are all system functions which makes it difficult to debug.
Really need some expert advice on this. Please read the forum mentioned above to be clear about the issue.
Whoa! I thought i knew NSZombies enough but i was wrong!
I enabled NSZombies which led me to:
*** -[ContactsViewController numberOfSectionsInTableView:]: message sent to deallocated instance 0x88dafa0
Doing "po 0x88dafa0" wont work because that object's memory was already freed.
Some more Googling led me to this where the author describes how to find freed/deallocated objects. We just have to set MallocStackLoggingNoCompact to 1 in the Variables to be set in the environment along with NSZombieEnabled.
The output i got with the info malloc-history 0xf270740 command had a line:
-[VoicePlayController actionSheet:clickedButtonAtIndex:] at /Users/Documents/Xcode Projects/Classes/VoicePlayController.m:454
The code on that line is:
contactsViewController = [[ContactsViewController alloc] initWithNibName:#"ContactsViewController" bundle:nil];
I moved the [contactsViewController release]; line to dealloc method instead of immediately after [self.navigationController presentModalViewController:contactsViewController animated:YES]; and the problem is gone!
Start with enabling NSZombies. What it sounds like is you are over-releasing an object.

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.