Objective-C tutorial?

Member
Posts: 28
Joined: 2008.06
Post: #1
I'm trying to figure out Objective-C and Cocoa, but I'm getting confused. Is there a good tutorial for migrating from C to Objective-C and Cocoa? If not, please recommend a learning path.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
I was gonna say search the forums, but even Google gave me junk for some reason. I guess I didn't figure out the magic werdz this time...

You'll want to purchase a copy of: Cocoa Programming for Mac OS X by Aaron Hillegass.

You will also want to read Apple's docs on getting started with objective-c and Cocoa.

There are a bunch of other places which I'm sure others will be quick to recommend, but those are the top two.
Quote this message in a reply
Member
Posts: 24
Joined: 2008.02
Post: #3
If you want to learn about the Objective-C language itself, I highly suggest Programming in Objective-C.

You might take a look over at CocoaLab and their BecomeAnXcoder online book, I found that to be helpful.

And last but not least, check out CocoaDev, it's a very comprehensive wiki for Cocoa. If I can't figure something out from the documentation, that site is the first thing I check for information.

Hope that helps!
Quote this message in a reply
Member
Posts: 28
Joined: 2008.06
Post: #4
Thank you!
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2007.02
Post: #5
Quote:You'll want to purchase a copy of: Cocoa Programming for Mac OS X by Aaron Hillegass.
I'll second this. That book is excellent and it made everything very clear to me coming from a C++/MFC background.
Quote this message in a reply
Moderator
Posts: 624
Joined: 2007.09
Post: #6
(Aside: are you the Willem from C3D forums?)

- Lincoln Green
http://www.binkworks.com/
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #7
Thirding Hillegass' book. Make sure you actually buy it, it's one of the cornerstones of the community's adoption of Cocoa, and I heard something about it not selling well due to PDF piracy. :/
Quote this message in a reply
Moderator
Posts: 624
Joined: 2007.09
Post: #8
Its a REALLY good book.

- Lincoln Green
http://www.binkworks.com/
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2007.02
Post: #9
Quote:(Aside: are you the Willem from C3D forums?)
Yep, same guy.
Quote this message in a reply
Member
Posts: 28
Joined: 2008.06
Post: #10
How would I get the value of an NSTextField in Interface Builder from the Obj-C code?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #11
computergeek6 Wrote:How would I get the value of an NSTextField in Interface Builder from the Obj-C code?

The interface (what you make in InterfaceBuilder) doesn't "get" a value from your Obj-C code, it gets "set" by your Obj-C code.
Quote this message in a reply
Member
Posts: 28
Joined: 2008.06
Post: #12
I know, but I can't figure out how to store the text from my NSTextField into an NSString. I have a button and a text-field in a window, the user has to put something in the field, then click the button, then the button sends an event to the instance of my class, then the class needs to get the text in the text field, and set the caption of the button to whatever is in the text field.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #13
Oh, I misunderstood your question! Sorry bout that... You can do:

NSString *theStringFromMyTextField = [myTextField stringValue];
[myButton setTitle:theStringFromMyTextField];
Quote this message in a reply
Member
Posts: 28
Joined: 2008.06
Post: #14
How do I set the name of the text field? In Interface Builder, or in code?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #15
Not exactly sure what you mean by "name". If you mean the text field's contents, you can do it from either IB or code:

[myTextField setStringValue:@"my title"];

or

[myTextField setStringValue:myString];
Quote this message in a reply
Post Reply