Appcelerator’s Titanium: Inherit from Ti objects.

So, in Titanium, you are unable to extend the native classes. You’re also unable to add methods to native objects or re-assign methods (so, if you wanted to, say, modify an object so that the “hide” function triggers an event, tough sh*t). There is, however, a decent way of getting around this inadequacy (read: violant violation of the ECMA standards, but who are we to judge).

var Klass = function(){
    this.toView = function(){ return Klass.prototype }
}
Klass.prototype = Ti.UI.createView({
    /*... the rest of the parameters here (as usual) ... */
});
var view = new Klass();

Then, if you want to add the object to a window, you need to remember to call win.add(view.toView()), but it means you can now carry around the data object with *all* of its data.

This entry was posted in Frameworks and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>