Problem
ScrollableView's "removeView" method accepts either a view or an index to a view, but passing in an index to a view results in an error being raised.
The Error
{quote}
2011-11-04 10:18:18.309 play[50939:1ab0b] -[__NSCFNumber krollObjectForBridge:]: unrecognized selector sent to instance 0x8c6d7a0
[ERROR] Script Error = -[__NSCFNumber krollObjectForBridge:]: unrecognized selector sent to instance 0x8c6d7a0 at app.js (line 3).
{quote}
Why This Happens
In TiScrollableViewProxy.m's removeView method, the "doomedView" is identified. But when we call self forgetProxy, we don't use the "doomedView", we use the "args", which will only be valid if a view was passed in, and not an integer.
See the following erroneous code, taken from 1.8.0 at the time of this ticket's inception:
[doomedView performSelectorOnMainThread:@selector(detachView) withObject:nil waitUntilDone:NO];
[self forgetProxy:args];
[viewProxies removeObject:args];
[self unlockViews];
Solution
Change those two references to "args" to "doomedView", and everything works as it should.
How To Reproduce
Drop the following in an app.js. If you get a modal error screen, the bug is present. If you don't, then everything is working as it should.
Ti.UI.createScrollableView({
views: [ Ti.UI.createView() ]
}).removeView(0);
Pull Request
https://github.com/appcelerator/titanium_mobile/pull/629
Added the pull request. A very simple fix...
Spun off [TIMOB-5996] for either adding this to Android and the docs, or removing it from iOS.
Tested on Ti Studio 1.0.7.201112061404 Ti Mob SDK 1.8.0.1.v20111207091653 OSX Lion iPhone 4S OS 5.0.1 Expected behavior is of no error being produced is shown
Reopening bug to add tag
Added tag.