working with multiple Targets

Discussion in 'Mac Programming' started by ruhi, Aug 4, 2009.

  1. ruhi macrumors member

    Joined:
    Jun 17, 2009
    #1
    Hello All,

    In my cocoa application i am having two targets, each with associated classes and Nibs.

    I have a single main() for now.

    I want to run my one target from another target's code.

    i think i need two separate main() function for eg: App1Main() and main() for both the targets. but how can i call one App1main() function from main().

    I guess i need to call NSApplicationMain but how ?? what arguments??

    Please help.

    Thanks,
    Ruhi.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Build App1 as an application, include that in the main app in the resources via a Copy File build phase then use the standard NSBundle methods to get the path to that executable and run if via the normal methods for running an executable (you can't directly call it's main function you need to use NSTask).
     
  3. ruhi thread starter macrumors member

    Joined:
    Jun 17, 2009
    #3
    working with multiple Targets

    what is the other method using NSTask. I want to know that too so that i could find the better one according to my requirement.

    Thanks,
    Ruhi.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Read the documentation then ask specific questions posting the code you are using: I'm not about to write the code for you. Stop being so lazy.
     
  5. ruhi thread starter macrumors member

    Joined:
    Jun 17, 2009
    #5
    working with multiple targets

    Sorry to say, But i have already done lot of research and then posted this query on the forum for help.

    I dnt find any way to call main() from NStask, though there are some methods to launch Path but still running second app's main() is what i desired.

    Thanks,
    ruhi.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    You don't call main(). You start a new process. The OS calls main(). That's what it's there for.
     
  7. ruhi thread starter macrumors member

    Joined:
    Jun 17, 2009
    #7
    working with multiple Targets

    Thanks.

    I am adding a build phase rather than using NSTask.

    There are many options for adding a build phase like:
    Copy Files Build Phase
    Compile Sources Build Phase
    etc.

    i am not able to add either of them.
    Can you tell me the suitable one that will do my task?

    Thanks,
    Ruhi
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    This makes no sense at all: they do completely different and unrelated things.

    I've no idea. Build Phases have nothing to do with calling another executable from within yours (and "calling main()" is another executable).
     

Share This Page