Begginer GUI Tutorial For C

Discussion in 'Mac Programming' started by Halfmaster1, Aug 24, 2011.

  1. Halfmaster1 macrumors newbie

    Joined:
    Dec 28, 2010
    #1
    Hello, I have Xcode, and a tutorial for C. I think that I understand the basics of C pretty well, but I have no idea how to use GUI, as the tutorial said nothing about it, and I can only use printf() to see what is happening in my program. Is there any tutorials that you guys know of on how to use GUI?
     
  2. PatrickCocoa macrumors 6502a

    Joined:
    Dec 2, 2008
    #2
    Clarify

    Are you asking about how to use Xcode, or are you asking about how to write programs that have GUI elements (windows, text fields, buttons, etc.)?

    If you're asking about how to write programs that have GUI elements, you'll need to move from C to Objective-C, and you'll need to use the Cocoa APIs.

    Objective-C is needed as that's what Apple requires to access Cocoa. Cocoa is required as that's what Apple requires to access their GUI elements (as well as Apple's implementation of arrays, dictionaries, and other elements).

    My advice is to find a tutorial on Objective-C and Cocoa. You will NOT be able to use C to create anything Mac-like on the screen. For instance, you will not be able to use C to write a line like "createWindow(x, y, width, height, title)". All of that is done in Objective-C by calling the Cocoa method that creates windows.
     
  3. Halfmaster1 thread starter macrumors newbie

    Joined:
    Dec 28, 2010
    #3
    Sorry if I didn't make my OP clear, I meant the GUI, yes. And sorry for the slow reply.


    So, no GUI at all in C. Well, that is disappointing. I'll look in my Objective-C tutorial, which I have, but didn't look at yet because I thought I should make something in C first.

    Or should I try C++. Is that like C? Because Objective-C is like a completely different language.
     
  4. PatrickCocoa macrumors 6502a

    Joined:
    Dec 2, 2008
    #4
    C++ is not what you want

    For native Macintosh and iOS application development, there is only Objective-C and Cocoa / Cocoa Touch.

    It sounds like you have a certain background and would like to use your existing skills to develop for the Mac / iPhone / iPad. Unfortunately that will not be possible. You can use your prior experience and understanding of computers to give you a slight head start on a complete newcomer, but you will need to forget much of what you know about how to do things.

    For native Macintosh and iOS application development, there is only Objective-C and Cocoa / Cocoa Touch.

    There may be a few posts after this telling you about Java or Ruby or C++ or some other things. Feel free to look into them, but if it were me I wouldn't spend too much time on them.
     
  5. LostSoul80 macrumors 68020

    LostSoul80

    Joined:
    Jan 25, 2009
    #5
    That's not true at all. You can use Carbon to code any GUI you want, and of course there are a lot of libraries written in C. C++ is also fine, as well as Java.
     
  6. notjustjay macrumors 603

    notjustjay

    Joined:
    Sep 19, 2003
    Location:
    Canada, eh?
    #6
    Well, it's because C is an old language that is designed to be portable. You write your code on a Mac, say, and the same program will run on a DOS PC or a graphing calculator. Programs written to use the console (printf etc) will run on pretty much anything.

    When you start writing code for GUIs then you're starting to specialize. Windows GUI programming is different from Mac GUI programming, which is different from programming for X/Motif or Qt (both of which will run on either platform), and you're no longer strictly talking about the C programming language so much as whatever enhancements or libraries are required to support the particular GUI you choose.
     

Share This Page