 |
 |
From Web to OS X
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Aug 2005
Status:
Offline
|
|
HI, I'm new to this forum so first off, HI!
I want to learn how to program for OS X. This post is simmilar to another post [teaching programming to a child] i've been reading, but with a fundamental difference, and here it is. I know how to program already. To be more precise, I know how to code for the web, HTML CSS PHP XML and ActionScript. I "know" about OOP although I'm still struggling with it, I guess I don't think that abstractly.
So i picked up an O'Riely book [learning Cocoa] and while I'm more than capeable of finishing all the examples, I'm not learning anything because i still don't get it [i gave up after the currency convertor example]. so, for example, from the following code,
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Hello, World!");
[pool release];
return 0;
}
i only understand that it's importing come kind of class, defining the main function (but i don;t know whats happening in the parenthesis), the comment, the print function NSLog() and the return value. The rest is a complete mystery and it looks ominously important.
I don't mind learning, my trails and tribulations with web development have taught me that, so i'll gladly go right back to basics (eg 'This is a computer and here is the 'on' button') but i've tried learning pure C and can;t even get past the Hello World! tutorial. I get a lot of errors form the following code when trying to compile with GCC
Code:
// Hello World!
#include </objc/Object.h>
@interface Greeter:Object{
// Empty for now
}
- (void)greet;
@end
#include (stdio.h)
@implementation Greeter
- (void)greet
{
printf("Hello, World!\n");
}
@ end
int main(void)
{
id myGreeter;
myGreeter=[Greeter new];
[myGreeter greet];
[myGreeter free];
return EXIT_SUCCESS;
}
The compiler gives me lot's of error, but they're of little use as I have no idea what they mean. If it can't find "Object.h" then where the hell is it????
I guess what i'm asking is where can I go and learn all about programming for OS X from the very begining. Theres a big difference between Web and OS X from what i can see and I'm about two days from quitting and sticking with flash MX. Looking around for litratire is mind numbing because it all assumes you know exactly what you want to learn, and thats half the battle! Whats the difference between Cocoa and Carbon?
So, if you've stuck with me this far then thanks for listening. But heres my question. Where should i start?
peace out
-t
by the way, my web stuff is here
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Carbon is a C API which is much larger and generally more complex to work with (though less so than it once was). Cocoa is an object-oriented API usually used with Objective-C, an object-oriented version of C. In either case, you'll probably want to learn C if you want to use them.
If you don't like C, you could try Java, or maybe Python or Ruby. They're somewhat higher-level. Java is extremely well-documented, too, at least the basics, though I prefer the latter two languages.
As for your code, there are two problems I see that seem to be what the compiler is complaining about, both with the #include directive.
The first time, you write #include </objc/Object.h>. This should be #include <objc/Object.h>. The objc include directory is not at the root of your hard drive, which is what you were specifying with the first slash.
The second time, you write #include (stdio.h), which isn't valid C at all. #include is not a function; it's a preprocessor directive. It tells the preprocessor to include the contents of the named file, which defines the Object class in this case. It looks like either #include <somefile> (if the file is in the compiler's include path) or #include "somefile" (if the file is specified from the current working directory).
As a side note, nobody uses objc/Object.h. You generally use NSObject, which is part of Cocoa, as your base class.
(Last edited by Chuckit; Aug 28, 2005 at 07:52 PM.
)
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: England
Status:
Offline
|
|
I've read the book you mentioned, and found it awful. A much better O'Reilley book is Building Cocoa Applications. It's a little old now (designed for OSX 10.1) but it taught me a heck of a lot.
Amorya
|
|
What the nerd community most often fail to realize is that all features aren't equal. A well implemented and well integrated feature in a convenient interface is worth way more than the same feature implemented crappy, or accessed through a annoying interface.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2002
Status:
Offline
|
|
Best yet is Aaron Hillegass' Cocoa Programming for Mac OS X for a good introduction to Cocoa. Slightly out of date, as it uses Panther for examples, but good none the less. There's also Stephen Kochan's Programming in Objective-C for a good introduction to the Objective-C language.
(Last edited by Thinine; Aug 30, 2005 at 04:22 PM.
)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|