Starting out in Cocoa

Discussion in 'Mac Programming' started by andysmith, Oct 2, 2004.

  1. macrumors 6502

    Joined:
    Sep 24, 2004
    Location:
    West Mids, UK
    #1
    I'd really like to create some apps for OS X, but I'm not sure where to start.
    I've never use C or C++, and I've only got a basic grasp of object based programing, mainly from PHP.

    Are there any books or tutorials that I can use?

    Thanks for any help :)
     
  2. macrumors 65832

    Joined:
    Aug 2, 2004
  3. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
  4. thread starter macrumors 6502

    Joined:
    Sep 24, 2004
    Location:
    West Mids, UK
    #4
  5. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #5
    With the other book recommendation :)

    http://www.amazon.co.uk/exec/obidos...23800/sr=1-1/ref=sr_1_8_1/202-3056260-2575813

    You really need to understand OO &&/|| C/C++ if you want to get a good understanding of Obj-C and Mac development. I must say so far, I like the book. I have cruised through the first 8 chapters so far and am trying to follow along with all the examples (especially the evolving Fraction class) using my interim system (a PC :( ) running Cygwin's gcc compiler and jGrasp (thanks bousozoku)
     
  6. thread starter macrumors 6502

    Joined:
    Sep 24, 2004
    Location:
    West Mids, UK
    #6
    That book looks good - so can I just use the examples in that OK with the XCode tools?
     
  7. macrumors regular

    Joined:
    Apr 16, 2003
    Location:
    Minneapolis, MN
    #7
    I'd strongly recommend the Aaron Hillegass book and forget about the "Programming in Obj-C" until later, or pick them both up simultaneously. Aaron's book deals more with the Cocoa frameworks, while Programming in Obj-C deals with, well, Obj-C. Obj-C is a superset of C; that is, it's exactly 100% the same as C with a tiny handful of additions (I think it adds one or two basic data types, and one new operator. It's amazing what Brad Cox, the guy who designed Obj-C, was able to accomplish so elegantly and simply.) However, if you're going to focus on Cocoa programs, you'll be spending alot of time trying to figure out how the frameworks are structured, and how best to utilize the powerful functionality therin. Yes, you will bump up against lower-level C programming, but it'll probably be infrequent until you start to grasp what you can accomplish within the Cocoa frameworks alone.

    The Hillegass book mixes enough theory, training and walkthroughs to lay some basic concepts down while giving you a grand tour of the Cocoa frameworks. Even if you don't understand everything in it, you should enjoy the process without getting frustrated. However, this isn't some watered-down, programming for dummies material. Aaron's been working with these frameworks long before Apple purchased Next computers. Here's a quickie bio:

    Bottom line: remember that it's completely AOK to be confused when learning. That's part of the process and if you weren't confused and challenged, I'd be concerned that you weren't learning much of anything. It all depends on your learning style. If you can, see if you can locate them at a local booksellers and browse first.

    Best,
    Logicat
     
  8. thread starter macrumors 6502

    Joined:
    Sep 24, 2004
    Location:
    West Mids, UK
    #8
    Thanks - very helpful :)

    I'll have a look for the books locally then - probably not for a while, I need to finish reading 'Mac OS X Panther in a Nutshell' (I want to fully get to grips with OS X first).
     
  9. macrumors member

    Joined:
    May 16, 2003
    Location:
    Eugene, OR
    #9
    As someone that has come from more of a Java background to Objective-C, I have one piece of advice: read carefully about memory management. This is very important for the transition from a language that is fully garbage collected(meaning when you create new objects, you don't have to delete them manually), to a language where you have to be more responsible with your memory usage.
     
  10. macrumors regular

    Joined:
    Apr 16, 2003
    Location:
    Minneapolis, MN
    #10
    And regarding memory management in Cocoa, it's not confusing once you learn it. Also, it's nothing like the low-level management of memory in C.

    There are two or three simple rules that, if followed, will prevent you from needing to worry about memory management and object persistance. Again, Hillegas' Cocoa book lays it out very simply.

    The other Cocoa book that has proven itself invaluable is "Cocoa Programming". It's my go-to book for answers to specific Cocoa implementation questions; there's not much in the way of tutorial work included. Different chapters cover specific classes, programming methods, and Cocoa philosophies. It's really a fantastic reference, and the most explicitly helpfull one I've seen.

    The only drawback of the 1st edition of "Cocoa Programming" is it only covers the API through 10.2. The 2nd ed. of Hillegas' book, now available, covers the bindings and controller additions of 10.3; an area that will radically change your programming methodology (as long as you expect to only release your software for 10.3 +).

    Best,
    Logicat
     
  11. macrumors member

    Joined:
    Sep 2, 2002
    Location:
    Near Insanity
    #11
    I picked up Hildegass' book both editions and find that they weren't all that helpful. Yes you simply type what is there and get the results he has, but without the underlying foundation in Objective-C most will be lost.
    "Programming in Objective-C" by Stephen G. Kochan is the best for learning the language and he also guides you into the Foundation framework. Once you understand this Cocoa is a snap. Starting at the other end and working your way back is confusing to everyone I've come across that starts programming for OS X this way. So I recommend andysmith go with "Programming in Objective-C" it's a must and then find a good Cocoa book. I don't find the Hidegass book all that friendly to noobs.
     
  12. macrumors newbie

    Joined:
    Oct 18, 2004
    #12
    Getting to grips with OOP

    If you have only done PHP then you might need to learn about OO programming, this site has a great introduction to OOP mainly aimed at Java developers but concepts work in Obj-C.

    http://sepwww.stanford.edu/sep/josman/oop/oop1.htm

    If you find tutorials for Obj-C hard to find try just learning C as 90% or more will work in Obj-C, in fact many languages can work in Cocoa making it very cool indeed!

    Actually you don't even need to do C, C++ or Java or Obj-C... you can make a pretty decent app using Applescript - check out the Apple developer site for more info
     
  13. macrumors 6502

    Joined:
    Jan 1, 2002
    Location:
    Baton Rouge, Louisiana
    #13
    if you download apple's developer tools, they should have a very fairly good tutorials. i downloaded the version they had about a year and a half ago and the included tutorial was pretty helpful. of course buying one of those books will probably be better, just not free (how i like things :D ).
     
  14. macrumors 6502

    netytan

    Joined:
    May 23, 2004
    #14
    Agreed, Applescript can be a good way to create small Apps, but I can't see myself - personally - using it for anything more than my own little utilities.

    On the subject of learning OOP you might want to look at Python. Besides Python being easy to pick up there’s also much more documentation on Python than there is Applescript. And since Python and Obj-C classes share the same roots - Smalltalk – you might find it of more use to you.

    Where as you might find classes in Java and C++ are a little different; they are more like PHP classes!

    Conceptually though, the ideas behind OOP are language neutral. Still, I think worth mentioning. But then I am pretty new to Cocoa myself :).

    Have fun,

    Mark.
     
  15. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #15
    I'm also new to the whole "Mac programming" thing. At least on anything since System 7. Coming from a strong Java background, it's requiring me to unlearn some stuff and has reinforced just how common basic OOP concepts are in other areas.

    I agree that Hillegass' book ("Cocoa: Programming for OS X") is a great (and thorough) intro to Cocoa. "Cocoa Programming" is also good, but just a bit cumbersome IMHO. However, I don't see any way around getting Kochan's "Programming in Objective C" concurrently with Hillegass.

    From my point of view, Cocoa provides you the keys to the GUI kingdom. Using Hillegass' examples, you'll learn to do most of what you need to learn in order to build a GUI, complete with interactions between components and with the user.

    However, to actually do anything aside from GUI logic, you need Objective-C (unless you punt and use Java to fill in the gaps... as I've been guilty of doing). And Kochan's book is an excellent intro to that language - and it doesn't require familiarity with any language first (he starts at the beginning and teaches Objective-C, as opposed to assuming you're coming from C or C++ or Java or whatever background).

    Before using Java, I used C++ for many years, and C before that. While I agree that Objective-C often looks like C (of course, since it's a superset), the differences are enormous in terms of how you use the language. Kochan does a great job of explaining it.

    As far as AppleScript: it's great for inter-application glue. It's good (but often tedious and mystery-prone) as a simple way of interacting with apps. But it's not as good as Python, Java, Objective-C, shell scripts, or really any other approach when you're not directly trying to tell other apps to do things. It's good to know, and very, very useful in its defined area, but not a great general programming tool.
     
  16. macrumors 65816

    hotwire132002

    Joined:
    Jan 24, 2004
    Location:
    Cadillac, MI
    #16
    I'm also trying to begin cocoa programming--is there a good online tutorial anyone can point out? The only link I saw in this thread was at the beginning--and I skimmed through it, but didn't see anything that looked great.

    By the way--I'm completely new to (any form of) C, so I need something that doesn't assume I know C.
     
  17. macrumors regular

    Joined:
    Apr 16, 2003
    Location:
    Minneapolis, MN
    #17
    Start at CocoaDevCentral for a pile of Cocoa articles (also compiled from Stepwise) and links to other reference material and tutorials.

    Other than that, start reading and coding. If you want to learn how to cut code, just start cutting code.

    Best,
    Logicat
     
  18. macrumors 65816

    hotwire132002

    Joined:
    Jan 24, 2004
    Location:
    Cadillac, MI
    #18
    Thanks for the help. I'll check it out :)
     

Share This Page