PDA

View Full Version : Getting into OS X Programming




Coolnat2004
Jul 20, 2006, 11:44 PM
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..



HiRez
Jul 21, 2006, 12:08 AM
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.

slooksterPSV
Jul 21, 2006, 12:57 AM
To develop OS X apps you need to know:
Objective-C and Cocoa or
Carbon and C++.

mduser63
Jul 21, 2006, 12:59 AM
To develop OS X apps you need to know:
Objective-C and Cocoa or
Carbon and C++.

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).

macsrockmysocks
Jul 21, 2006, 01:25 AM
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).

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!

slooksterPSV
Jul 21, 2006, 02:33 AM
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!
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:


//main.m
//Editied by: your name

#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.

macsrockmysocks
Jul 21, 2006, 02:52 AM
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:


//main.m
//Editied by: your name

#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.

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

maximile
Jul 21, 2006, 04:53 AM
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.

HiRez
Jul 21, 2006, 01:25 PM
There is your first Objective-C app.Technically, that's actually a C application, there is no Objective-C in there.

Soulstorm
Jul 21, 2006, 02:01 PM
Technically, that's actually a C application, there is no Objective-C in there.
There is the '#import' preprocessor function :P

therevolution
Jul 21, 2006, 02:42 PM
There is the '#import' preprocessor function :P
Which is also part of C...

slooksterPSV
Jul 21, 2006, 03:46 PM
Gotta start simple, I could have given him an app like this and really confused him:


//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

macsrockmysocks
Jul 21, 2006, 04:29 PM
Gotta start simple, I could have given him an app like this and really confused him:


//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

Thanks for not trying to confuse me... but ^ did:o lol.

slooksterPSV
Jul 21, 2006, 05:16 PM
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

DaveP
Jul 21, 2006, 05:39 PM
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.

Coolnat2004
Jul 21, 2006, 08:38 PM
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.
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.