Integrate titanium with native code

You must Login before you can answer or comment on any questions.

Hi all,

Can i integrate titanium generated native code(for iphone) with the objective c code??

Thanks

— asked 2 years ago by mathew orleans
1 Comment
  • Sorry for the duplicate question, but it showed me the red screen that smthing went wrong ......

    — commented 2 years ago by mathew orleans

2 Answers

Can you elaborate on what you mean by integrating "with the objective c code"?

It sounds like you are asking if you can use Titanium to generate some obj-C code, then take that and insert it into another obj-C project in XCode.

If so, then you have it backwards.

You can integrate other obj-C code into a Titanium project by putting that native obj-C code into a "module" then referencing that from your Titanium project. See this guide for documentation on creating iOS modules.

As far as I know, you can't go the other way around and insert parts of a Titanium project into another XCode project.

I suppose you could in theory take the XCode project generated by Titanium and directly modify it. But IMHO that would be a VERY poor idea. It would preclude you from easily making changes to the Titanium project source and recreating the XCode project.

Also, you may have a misconception on how Titanium works. It does not take your javascript source and automagically translate it into obj-C code. You may find it instructive to look at these messages on how it works:

— answered 2 years ago by Doug Handy
answer permalink
3 Comments
  • Hi doug , Thanks for your reply. I wanted to ask that may i reference the native code module(Xcode project) by the native code generated by titanium in titanium project.

    — commented 2 years ago by mathew orleans

  • SoRRY if i cant make you understand,

    I want to ask that may i embbed the native code module(Xcode project) into the native code generated by titanium(Iphone) in titanium project.

    — commented 2 years ago by mathew orleans

  • Just noticed you had made a reply here. Don't know why I didn't get email notification, because I am subscribed to the thread.

    Anyway, it is still not clear to me what you are trying to insert into the titanium project. When you say you want to embed "the native code module (Xcode project)" are you talking about an iOS module as in this guide for creating modules to extend Titanium?

    If so, revisit that guide, particularly step 1.

    But I am not even sure you are talking about that type of module.

    — commented 2 years ago by Doug Handy

This is the code to show date picker dialog.

var tempDate = new Date();
 
 
            // This picker only supports android platform
            var picker = Ti.UI.createPicker({
                type : Ti.UI.PICKER_TYPE_DATE,
                minDate : new Date((tempDate.getFullYear() - 10), 0, 1),
                maxDate : new Date((tempDate.getFullYear() + 10), 11, 31),
            });
 
            picker.showDatePickerDialog({
                value : new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate()),
                callback : function(e) {
                    if (e.cancel) { // User clicks on cancel button
                        Ti.API.info('User canceled dialog');
                        alert("User canceled date");
                    } else { // User selects set or done button.
                        Ti.API.info('User selected date: ' + e.value.getFullYear());
                        alert("user selected date:"+e.value.getFullYear());
                    }
 
                }
            });
Everything is working well and fine up to android v2.3.6. Up to 2.3.6 date picker dialog is showing both set and cancel buttons. So when ever user clicks on set button then
alert("user selected date:"+e.value.getFullYear());
this alert dialog is executing.

If user clicks on cancel button

alert("User canceled date");
this alert is executing.

But the problem is from Android v4.0. Date picker dialog is only showing done button. If user clicks on done button then

alert("user selected date:"+e.value.getFullYear());
alert is executing perfectly.

If user wants to cancel the dialog then either he needs to press back button or click on out side of date picker view. This means user canceling the dialog even though

alert("user selected date:"+e.value.getFullYear());
the same selected alert box is executing. How to solve this problem.

Your Answer

Think you can help? Login to answer this question!