Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ruhi

macrumors member
Original poster
Jun 17, 2009
70
0
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.
 
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).
 
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.
 
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.

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.
 
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.
 
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.

You don't call main(). You start a new process. The OS calls main(). That's what it's there for.
 
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
 
Thanks.

I am adding a build phase rather than using NSTask.
This makes no sense at all: they do completely different and unrelated things.

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

I've no idea. Build Phases have nothing to do with calling another executable from within yours (and "calling main()" is another executable).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.