More fun, curious obj-c questions
More fun, curious obj-c questions
- Subject: More fun, curious obj-c questions
- From: Scott <email@hidden>
- Date: Tue, 29 May 2001 02:57:06 -0700
Points:
* Thanks for all the replies of great insight! There were some really
great ones in there that helped form some new mindsets. The sludge is
clearing on how to approach obj-c/cocoa.
* I LOVE all the humor. Keep it up!
* Okay, confusion setting in. The following declaration makes sense in
it's own circumstance:
-(void) setWidth:(float)width height:(float)height;
but the abstraction loses consistency in:
-(void) mouseDown:(NSEvent *)theEvent;
Here, the method name has nothing to do with the parameter passed, where in
the first example, setWidth:height:, the words setWidth have everything to
do with describing the first parameter.
My ambiguity meter just blew up and landed across the room in pieces.
Why not just declare the first as:
-(void) setWidthHeight:(float)width :(float)height;
Then, when I call the method, it looks like:
[myRect setWidthHeight:10.0 :10.5];
Much more readable to me.
Or, would this be correct/possible?
-(void)setBounds width:(float)width height:(float)height;
^
BTW, answering these kinds of questions, odd as they may seem, helps me
figure out the boundaries of things and why they are designed the way they
are. In order to think outside the box, you have to attack the walls. I
may never do any of this stuff, but nonetheless, it helps greatly. I'm an
academic at heart (with 21 yrs programming experience.)
* Are Obj-c method calls ordered as to parameters?
Is:
-(void) setTop:(float)top left:(float)left bottom:(float)bottom
right:(float)right;
The same as:
-(void) setTop:(float)top bottom:(float)bottom left:(float)left
right:(float)right;
I would guess not, but something about not using commas wants me to think
this.
* So, when Obj-c gets compiled, does this mean there's an extra layer to
the calling structure? It sounds like a message is interpreted before the
runtime system figures out where to direct the pc.
* the "+" vs. "-" thing:
I can't for the life of me conceive of a time when I would care about the
difference btwn class and instance methods, but I'm sure someone put it in
there for a reason. Anyone got some examples of when I would use a class
method over an instance method?
* Doc site:
I'm creating a site with tips, tricks, hints, general info for c++->obj-c
converts like myself. If anyone has any additional insights on how to
approach obj-c with a c++ mentality, please send them to me at:
mailto:email@hidden
Also, please send me any GOTCHAs -- i.e. Stuff you found frustrating because
it worked differently than you expected, whether it be re: obj-c syntax,
mindset required for obj-c or the IB or PB interaces. Come on, there has to
be something that got you when you were learning. <g> Come on, what was it?
Some of the difficulty in migrating to OSX development is in learning the
new concepts involved and expecting them to conform to past OOP experience.
If you know what you're looking for, it's mostly available in the current
docs, but if you haven't a clue, you're stuck.
I think we've got some great technologies in front of us but they're miles
apart from where we were with Metrowerks and will take some time for
everyone to catch up.
Thanks much!
Scott
p.s. Greg, thanks for saying "willy-nilly" -- LOL!
------
"The cyber-profession that kicks ass and gives names..."
http://www.domainjane.com