Re: Beginner's questions
Re: Beginner's questions
- Subject: Re: Beginner's questions
- From: email@hidden
- Date: Tue, 16 Oct 2001 22:56:34 +0930
On Tuesday, October 16, 2001, at 06:54 PM, Philippe Magdelenat wrote:
Q) What about abstract class (in the java meaning of abstract class) ?
A) I've seen the previous answer and ok but it's still too bad...
There is no formal mechanism for abstract class, you can in the init
methods do something like
NSAssert1( ![self isMemberOfClass:[MyClass class]], @"You idiot, this
class %@ is abstract", [self class] );
Q) Is there anything like a private, protected, public method in
Objective
C. I know that we speak of message and not of method but still, it
would be
nice to restrict the availability of messages considering their scope
(am I
clear ?)...
At the begining of your implementation file (.m) do something like
@interface MyClass (private)
@end
you can create separate head files containing different categories of
the same class and import them independently to get protected like
effect. Mind you in java protected and public for methods behaves the
same within the same package and since there are no name spaces
(packages) with Objective-C then you get protected methods in a glass
half full kind of way, actually the catagories way is more flexible.
Q) Still in java, is the notion of package (or something close)
available to
organize my classes .
Yes stick PM (your initials) or some other initials (not NS) in front of
your class names (yuk I known) this is one feature it would be nice if
Objective-C had. (may the flame wars begin).
Q) Isn't the [[receiver message1:xxx] message2:yyyy:zzzz] a little
outdated
? Especially on a mac keyboard where no [ or ] is available ? Yes I
know how
to type them but still...
What do you mean there are no [ ] on the mac keyboard, on my keyboard
they are between P and \. The formate of messages in objective-C is
important because polymorphism (is that how you spell it) works
independently of any class hierarchy and therefore don't live in any
name space, so if you had a java type syntax and you had the method
setRect( float x, float y, float width, float height) this would be the
same method defined in another class as setRect( float left, float top,
float right, float bottom). With objective-C you instead have
setRectX:Y:width:height: which is different to
setRectLeft:right:top:bottom: a little bit of an artificial example but
still you can see my point. You could of cause call you java method
setRectXYWidthHeight(...) but who does. I don't know how the Objective-C
modern syntax got around this. The Objective-C syntax will grow on you.