Getting into OS X Programming

Discussion in 'Mac Programming' started by Coolnat2004, Jul 20, 2006.

  1. macrumors 6502

    Coolnat2004

    Joined:
    Jan 12, 2005
    #1
    I have been writing PHP scripts for a while.. albeit not object-oriented ones (I haven't been able to find a scenario where that would be useful.. YET..). I've done a few simple Python scripts.. and I have a C book and a Python book over there collecting dust. I'm going to take a "Computer Science" course at my high school this year.. which supposably starts you out with Visual Basic to learn the concepts (?) and then dives into Java. I'm afraid that it's going to be a dumbed down "Use a program that writes the code for you" course.. but we'll see.

    What I would like to do is start making some simple OS X applications. Where should I start?

    Thanks in advance.

    Edit: I understand that PHP supposedly is a bad first language to know because of it's freeness of variable types. However, I fully understand that concept so.. yeah..
     
  2. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    This exact same thread is started about once a week. Just do a search in this board and you will come up with lots of info, no need for everyone to repost it all again. There's even a sticky that has a lot of good resources to get you started.
     
  3. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #3
    To develop OS X apps you need to know:
    Objective-C and Cocoa or
    Carbon and C++.
     
  4. macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #4
    And my recommendation would be to learn Objective-C and Cocoa if you really just want to develop Mac apps. Programming in Objective-C by Stephen Kochan and Cocoa Programming for Mac OS X by Aaron Hillegass are the two books you should get (in that order).
     
  5. macrumors regular

    Joined:
    Feb 21, 2006
    #5
    Those are the books I just ordered for me to get started. All the reviews looked good, so I am taking the dive. They should arrive in a couple of days:) , but Hurricane Katrina ravaged areas can take 10+ more days to arrive:mad:

    EDIT: I am going crazy waiting for these books!! I can't wait to start!
     
  6. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #6
    Here, here's a program you can try out:
    Open XCode and start a new project (File->New Project... CMD+SHIFT+N)
    Ok so go down to Cocoa App, we're not developing a cocoa app, but its what we have to use.
    Choose a name for it and click Create, now open main.m and change the entire thing to look like this:

    Code:
    //main.m
    //Editied by: [i]your name[/i]
    
    #import <stdio.h>
    
    int main(int argc, char* argv[])
    {
     printf("Hello World! Welcome to the world of programming.\n");
     return 0;
    }
    
    Click the build icon with the hammer to build and run the app, you'll notice a window pop-up that has text in it with the text: Hello World! Welcome to the world of programming.
    There is your first Objective-C app.
     
  7. macrumors regular

    Joined:
    Feb 21, 2006
    #7
    Hey, thanks for the invitation. Well, since its so late,( and my friends are making me do certain things tomorrow...:( :rolleyes: ) I am going to do that tomorrow. Hopefully the book will explain this in much more detail. I hope you guys will be able to hellp me.:D
     
  8. macrumors member

    Joined:
    Oct 27, 2003
    Location:
    Herefordshire, UK
    #8
    Rather than diving straight into Objective C, you could consider making an interface around some of your Python scripts with PyObjC or something. Might be an easier way to start.
     
  9. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #9
    Technically, that's actually a C application, there is no Objective-C in there.
     
  10. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #10
    There is the '#import' preprocessor function :p
     
  11. macrumors 6502

    Joined:
    May 12, 2003
    #11
    Which is also part of C...
     
  12. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #12
    Gotta start simple, I could have given him an app like this and really confused him:

    Code:
    //main.m
    #import <stdio.h>
    #import <objc/Object.h>
    
    @interface Square : Object
    {
     int originX, originY;
     float side;
    }
    
    - (void)setSide:(int)length;
    - (void)setOriginX:(int)x;
    - (void)setOriginY:(int)y;
    - (void)setOriginX:(int)x andOriginY:(int)y;
    - (float)area;
    @end
    
    @implementation Square
    - (void)setSide:(float)length
    {
     side = length;
    }
    
    - (void)setOriginX:(int)x
    {
     originX = x;
    }
    
    - (void)setOriginY:(int)y
    {
     originY = y;
    }
    
    - (void)setOriginX:(int)x andOriginY:(int)y
    {
     originX = x;
     originY = y;
    }
    
    - (float)area
    {
     return side*side;
    }
    @end
    
    int main(int argc, char* argv[])
    {
     Square *mySquare = [[Square alloc] init];
     [mySquare setSide:10.0];
     [mySquare setOriginX:120 andOriginY: 200];
     printf("%.2f", [mySquare area]);
     [mySquare free];
     return 0;
    }
    
    But come on, he'll learn that, I don't think i wanna scare the kid with that much code, that's why I did a basic Objective-C program. Yes the first program I posted was Objective-C using the standard library, it was a .m extension and used the #import preprocessor directive
     
  13. macrumors regular

    Joined:
    Feb 21, 2006
    #13
    Thanks for not trying to confuse me... but ^ did:eek: lol.
     
  14. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #14
    Sorry, but the posters below were saying that the first prog had no Objective-C (obj-c for short) and they're right; its where you start in the book, its a start to Objective-C
     
  15. macrumors 6502

    Joined:
    Mar 18, 2005
    #15
    And don't necessarily count out your VB class. That's where I started with programming. One of the things I really enjoyed was being able to make legit-looking Windows apps pretty simply. And if you get further into Windows programming getting familiar with Windows forms is quite helpful.

    Also, you don't need to restrict yourself to only what your teacher wants. I did a lot of extra work as well as talking with my teacher and getting aproval to alter the assignments so they were a little more challenging.
     
  16. thread starter macrumors 6502

    Coolnat2004

    Joined:
    Jan 12, 2005
    #16
    Oh, definitely. I'm going to be going far above what's actually in the class, and I already know the teacher so she'll let me. I'll get a lot out of it I'm sure.
     

Share This Page