简体   繁体   中英

Cocoa Objective-C main loop

I'm building an application in C, which is a client/server sharing app. This application is command line based which uses TCP sockets, libcurl and some fork(). It should run in an infinite loop without any input.

My professor at the university said that we have to implement a GUI, and because I'm on Mac, I learned Object-C and I have done it in cocoa.

Now I'm asking myself if could be possible to merge the two applications, the cocoa GUI and the real application written in C. Of course I need the two "apps" to run in parallel.

Can I add it to my cocoa app? Where I have to put the code in order to have it always running? Not in awakeFromNib right? I know that the question is kind of vague.

Thanks.

You could run the command line app as an NSTask and write the appropriate code so that they can commnicate via pipes. This way they will run asynchronously.

Alternatively you could definitely 'merge' them as c code will run just fine in an ObjC progam. The infinite loop could live in a different thread. Although this solution may require more re-writing than the previous solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM