+ Reply
Results 1 to 2 of 2

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Language Comparison

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
iPhone Language Comparison ...A theoretical thread Picking up a good book on cocoa/objective-c never hurts, but isn't always the best universal starting point either. My intention is to help people
...
  1. #1
    What's Jailbreak? MikeTV's Avatar
    Join Date
    Aug 2007
    Posts
    18
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Lightbulb Language Comparison
    iPhone Language Comparison
    ...A theoretical thread

    Picking up a good book on cocoa/objective-c never hurts, but isn't always the best universal starting point either. My intention is to help people get a better feel for objective-c, if crossing over from another language.
    Below, I have posted what it might look like to code native iphone apps in other high-level programming languages, versus the standard objective-c.

    Code:
    // Creating a window (Obj-C)
    //--------------------------
    - (void)applicationDidFinishLaunching:(GSEventRef)event;
    {
        UIWindow *window = [[UIWindow alloc] initWithFrame:[UIHardware fullScreenApplicationContentRect]];
        [window setContentView:[[UIView alloc] initWithFrame:[window bounds]]];
        [[window contentView] setBackgroundColor:GSColorCreateColorWithDeviceRGBA(1.0, 0.0, 0.0, 1.0)]; // red background
        [window orderFront:nil];
        [window makeKey:nil];
    }
    Code:
    // Creating a window (C++)
    //------------------------
    private void applicationDidFinishLaunching(GSEventRef event) {
        UIWindow *window = UIWindow.alloc() -> initWithFrame(UIHardware.fullScreenApplicationContentRect());
        window.setContentView(UIView.alloc() -> initWithFrame(window.bounds()));
        window.contentView() -> setBackgroundColor(GSColorCreateColorWithDeviceRGBA(1.0, 0.0, 0.0, 1.0)); // red background
        window.orderFront(null);
        window.makeKey(null);
    }
    Code:
    ' Creating a window (VB)
    '-----------------------
    Private Sub applicationDidFinishLaunching(ByRef event As GSEvent)
        Dim window As UIWindow = New UIWindow( window.initWithFrame(UIHardware.fullScreenApplicationContentRect()) )
        window.setContentView(New UIView(initWithFrame( window.bounds() )))
        window.contentView.setBackgroundColor(GSColorCreateColorWithDeviceRGBA(1.0, 0.0, 0.0, 1.0)) ' red background
        window.orderFront(nothing)
        window.makeKey(nothing)
    End Sub
    Feel free to post additions/corrections and I will update accordingly.

  2. #2
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    If anyone wants a good UIKit introduction without having to deal with ObjC, check out Jay Freeman's "JocStrap" wrap of UIKit for Java. The JamVM virtual machine has been ported to the iPhone, and so one can start off by programming in Java.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts