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

shikha123

macrumors newbie
Original poster
Apr 21, 2009
8
0
I have a small doubt. I have written a code in C and tried running it on XCode using command line utility's Standard tool. I am able to see the output on console. But, now I want to see the same output on the iphone simulator. So, finally the question, is there an easy way to do this...or do I have to learn about building a GUI for my codes?
 
I have a small doubt. I have written a code in C and tried running it on XCode using command line utility's Standard tool. I am able to see the output on console. But, now I want to see the same output on the iphone simulator. So, finally the question, is there an easy way to do this...or do I have to learn about building a GUI for my codes?

Use Interface Builder (it comes with xCode)
 
Thanks so much... But could you please give some pointers on how to go about the interface builder..? As far as I know, the interface builder can be run only in Objective C. Pardon my little knowledge on the suject :). I am new to Xcode..
 
The problem is that you assume that the iPhone has a command-line interface (like the one in XCode), but it does not. Apple has done this because they want iPhone apps to be easy to use, and interpret that to mean GUI apps.

So there is not generally a Terminal app to interpret stdout. You are gust going to have to get used to writing GUI apps. You can still just wrap them around your C code, but you should get used to the system, rather than trying to force the iPhone environment to match what you are used to.
 
Hello,

Thanks for the reply. I do understand that the command line application is not supported by iPhone. But, I have a submission in a few days from now. So, for the time being could you suggest a work around wherein I can use my C Program as an iPhone application i.e the output gets displayed on the simulator rather than console.

Thanks once again.

Warm regards,
Shikha
 
The suggestion I would have is to convert it to an iPhone application by building a single interface in interface builder that has an input field, and an output field. You can then wire up a controller to those two fields, and when you get some input on the input field you can simply run your existing C code to manipulate this data, then set the output field to what you would have printed to the console.

You may have to turn some C strings into NSStrings and vice-versa, but that isn't too involved.

-Lee

Note: I am not sure what your application does, exactly, but something this bare-bones is unlikely to be... let's say, very popular in the app store.
 
Actually, my C code is the implementation of the TCP protocol.It has a client and server program. The client sends the data which is being received by the server. Now the problem is the client( which is just a socket C program) has to run on the iPhone and the server is Mac. Both of them are connected via Wifi.The problem lies with the client program as I need to import it on iPhone. The server part is running ok.
 
Actually, my C code is the implementation of the TCP protocol.It has a client and server program. The client sends the data which is being received by the server. Now the problem is the client( which is just a socket C program) has to run on the iPhone and the server is Mac. Both of them are connected via Wifi.The problem lies with the client program as I need to import it on iPhone. The server part is running ok.

Getting this to run is quite simple. You'll have to get one of the iPhone sample applications working first. You won't get around learning _some_ Objective C / Cocoa programming to do that. Add an "awakeFromNib" method in the right place, and call your C code from that method. Sockets work just fine both on the simulator and on the real iPhone, so if your code works when server and client run on two different Macs, it should work on Mac and iPhone as well.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.