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

0

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
)
iphone
asked on Stack Overflow Jul 8, 2010 by syoleen • edited Jul 8, 2010 by Alex Wayne

3 Answers

3

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!

answered on Stack Overflow Jul 8, 2010 by John Franklin
0

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

answered on Stack Overflow Jul 8, 2010 by vodkhang
0

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.

answered on Stack Overflow Jul 9, 2010 by syoleen

User contributions licensed under CC BY-SA 3.0