Sandy
Sandy

Reputation: 353

Native Code Generation in Titanium

How is native code generated in Titanium ?? I have read the documentaion on the internet and from it i can only understand the high level architecture but i need more details about the in depth working. For eg. when we create a button in Titanium using Ti.UI.createButton() how is this binded with native code and how do we get the same button as we get using native code.

Is UIButton object created and returned (talking only abt iOS) or the execution flow is different ? Also where should i look in the native code to for better understanding ?

Upvotes: 1

Views: 281

Answers (1)

Josiah Hester
Josiah Hester

Reputation: 6095

First of all, how it works is different for each platform, so it is impossible to generalize effectively since the platforms are so specific.

For iOS Titanium uses native bridge wrapper objects called a KrollObject. These proxy objects form a bridge from a Javascript object to the native object in native code. For your UIButton use-case, the UIButton is created but is not returned to the Javascript, you control it through the Kroll bridge. (As a side note, Kroll is the process of refining the material titanium, punny).

Really you dont need to know the really intrinsic details of how it works to write modules, especially since it requires a huge amount of native platform knowledge (in which case theres no reason for you to use titanium).

Here is a great video on how it all works from the last Codestrong. If you really want to know how garbage collection and lifecycle of objects works study this video.

Upvotes: 1

Related Questions