 |
 |
Complex Cocoa examples
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2001
Location: North America
Status:
Offline
|
|
I learn from example and I find that the examples on the developer disk are pretty simple. Most of the inheritance is from NSView or something very high level and don't give me enough code to induce what Obj C is all about.
Does anyone know of some more complex cocoa examples? Maybe the Fire app???
thanks,
john
|
|
My life is my argument. --Albert Schweitzer
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
Just look on version tracker at all of the Mac OS X software. A lot of it is open source. What do you mean by too high Level? Do you want to write directly to the screen without using an NSView? You can take a look at Apple's color bar example if that is what you want to do, but that only shows you how to take over the entire screen, not write to a part of the existing screen.
What is Objective C all about? It's all about nice inheritance like that. you don't need to write a lot of code because the libraries are awesome. You can make a rather professional looking program in Cocoa in much less time than it's take in Carbon. Why write your own code describing window behaviour when it's already there for you. Also, if the windows don't work quite the way you want them to, that's where inheritance comes in handy; you can customize lots of stuff. I wanted a slider that I could make act like the one in the RGB Color picker but Apple didn't have any color slider API so I just subclasses NSSlliderCell overrode the - (void)drawBarInside  NSRect)aRect flipped  BOOL)flipped; method and drew the bar that was appropriate for that slider. Moral: Cocoa is very nice.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2001
Location: North America
Status:
Offline
|
|
Thanks Dalgo,
When I said high-level, I meant too high in the family tree. I want to do exactly what you say, use inheritance. I wasn't trying to do low level code. However, most examples seem to use NSObject or NSView which aren't very extended as they stand, so I can't get a good sense of how to use things like inheritance, in general, and initialization of subclasses in specific. Is Obj-C more like C, C or Java in terms of its OO?
I tried reading the Obj-C guide from Apple, but I found it short on language constructs, and grammar, like how to extend a class. The simple program I wrote crashes with an SIGSEGV 11 error even though it compiles.
I checked out Fire.app and it is mostly inheriting from NSObject which is non too useful. In fact I have never used a library where the top object is used directly for inheritance, so that confuses me. It is such a general object I wonder how it can be useful in a GUI environment.
Thanks for the reply!
John
|
|
My life is my argument. --Albert Schweitzer
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Nov 2000
Status:
Offline
|
|
Everything must inherit from NSObject - that is the root of the OO tree for Cocoa.
Have u read this?
/Developer/Documentation/Cocoa/ObjectiveC/ObjC.pdf
That might help, or try the Help menu on Project Builder and look at Cocoa Help. There is tons of info there.
------------------
Timothy Hatcher
Programmer/Designer @ MainNet Incorporated
__________________________________________
http://www.main-net.com
|
|
Timothy Hatcher / xenon
.:[ massinova.com ]:.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2001
Location: North America
Status:
Offline
|
|
Yeah, I've checked out most of those sources. The ObjC.pdf is not as full of code as I like. And having examples that only use one or two objects for inheritance is not helpful either.
I guess I'll have to wait for the books to start coming out. I need a Objective C for C/C++ programmers kind of book that shows how ObjC does things. Java was like that at first too. I needed a third party book, I couldn't understand some of the syntax right away.
thanks,
John
|
|
My life is my argument. --Albert Schweitzer
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Some of the examples in /Developer/Examples/{AppKit, Foundation} seem relatively complex
There's also Vermont Recipes from Stepwise (www.stepwise.com).
It's actually often quite difficult to learn from more complex examples, since you tend not to have a clue about what's going on or what the programmer intended, unless the source is heavily commented. Vermont Recipes is meant as a tutorial, I'm not sure how complex it gets, I haven't actually bothered reading beyond the first part yet - been too busy trying to figure out the Hotline protocol and OmniNetworking
[This message has been edited by Angus_D (edited 04-08-2001).]
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2001
Location: Portland, OR, USA
Status:
Offline
|
|
Originally posted by SillyMonk:
Yeah, I've checked out most of those sources. The ObjC.pdf is not as full of code as I like. And having examples that only use one or two objects for inheritance is not helpful either.
Well, as Angus sort of mentioned, if you are really looking for huge complicated examples, there are the Omni frameworks at http://www.omnigroup.com/community/d...er/sourcecode/ - There's about 150,000 lines of Obj-C code there.
In general you tend to use composition patterns much more often than inheritance when you add functionality in Objective-C, so that means that inheritance hierarchies are much more flat and broad (many many subclasses at the same level, inheriting from the same base class, like NSObject or NSView).
In contrast, C++ (and Java to a lesser extent) tends to emphasize adding functionality through subclassing, so inheritance hierarchies tend to be very deep and narrow.
If you are a beginner and you are subclassing something in Obj-C other than NSObject and NSView, it is very likely that you are doing something wrong. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2001
Location: North America
Status:
Offline
|
|
Originally posted by gregomni:
Well, as Angus sort of mentioned, if you are really looking for huge complicated examples, there are the Omni frameworks at http://www.omnigroup.com/community/d...er/sourcecode/ - There's about 150,000 lines of Obj-C code there.
In general you tend to use composition patterns much more often than inheritance when you add functionality in Objective-C, so that means that inheritance hierarchies are much more flat and broad (many many subclasses at the same level, inheriting from the same base class, like NSObject or NSView).
In contrast, C++ (and Java to a lesser extent) tends to emphasize adding functionality through subclassing, so inheritance hierarchies tend to be very deep and narrow.
If you are a beginner and you are subclassing something in Obj-C other than NSObject and NSView, it is very likely that you are doing something wrong.
Thank you! I found out about OMNI about ten seconds before I read your post! And yes, I come from C++ and so deeper subclassing seems normal to me.
I was doing many things wrong and still am but my progam is getting written slowly!
-John
|
|
My life is my argument. --Albert Schweitzer
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

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