Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5990] iOS: Scrollable View removeView(int) Causes Error

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T18:03:23.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sRelease 1.8.0
ComponentsiOS
Labelsmodule_scrollableview, qe-testadded
ReporterDawson Toth
AssigneeDawson Toth
Created2011-11-04T09:23:59.000+0000
Updated2014-06-19T12:43:03.000+0000

Description

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

Comments

  1. Dawson Toth 2011-11-04

    Added the pull request. A very simple fix...
  2. Dawson Toth 2011-11-04

    Spun off [TIMOB-5996] for either adding this to Android and the docs, or removing it from iOS.
  3. Michael Pettiford 2011-12-07

    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
  4. Wilson Luu 2012-01-04

    Reopening bug to add tag
  5. Wilson Luu 2012-01-04

    Added tag.

JSON Source