C in iPhone

Discussion in 'iOS Programming' started by fernandovalente, Apr 11, 2009.

  1. macrumors 6502

    fernandovalente

    Joined:
    Aug 29, 2008
    Location:
    Third world **** hole, I mean, Brazil
    #1
    May I use C or at least some C functions in iPhone programing.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Of course you can. Objective-C is just a superset of C.
     
  3. thread starter macrumors 6502

    fernandovalente

    Joined:
    Aug 29, 2008
    Location:
    Third world **** hole, I mean, Brazil
    #3
    Thank you! Two more questions. May I use only C(without use the superset of C)? Will my app become unstable?
     
  4. macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #4
    You need to write the skeleton of the application in Objective-C, as the OS communicates to the app using Objective-C only. Also all of the iPhone UI is done using Objective-C.

    If you code what ever you do properly, it will have no effect on stability.
     
  5. macrumors 6502

    mccannmarc

    Joined:
    Aug 15, 2008
    Location:
    Manchester, UK
    #5
    The source code for Wolfenstein on the iPhone is all C they have just used the AppDelegate as an entry point to the app and to call their C functions to run the game. (Obviously they use Obj-C for iPhone specific stuff such as accelerometer etc but the core of the game is all C)

    In fact the code is a very interesting read to anyone who is mainly a C developer as it demonstrates the use of heavy C code on the iPhone and would answer most of your questions
     
  6. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #6
    You can use straight ANSI C as long as your app doesn't use require any UI interaction (any user input or window output), and runs less than 20 seconds.

    For instance, you can write an app that makes a posix network connection, downloads some data and plays a PCM sound waveform without writing any Objective C (or maybe 3 or 4 lines of it), other than in the templates.

    Otherwise you will need to use some Objective-C to access the UIKit frameworks for any UI (touches, accelerometer, windows, views, etc.), and the main run loop.
     

Share This Page