Re: Objective C language [NEWBEE QUESTIONS]
Re: Objective C language [NEWBEE QUESTIONS]
- Subject: Re: Objective C language [NEWBEE QUESTIONS]
- From: Jörn Salewski <email@hidden>
- Date: Fri, 30 Jan 2004 14:19:33 +0100
am 30.01.2004 13:08 Uhr schrieb Alexander F. Hartner unter
email@hidden:
>
I have been playing with objective C for some time now, but the number
>
of questions seem to increase as I learn more about the language. My
>
background lies in Java development so I am familiar with OO.
>
>
>
1. ) Private methods:
>
Is it possible to declare a method as private.
No.
>
From what I found out so
>
far it is not, but a similar behaviour may be achieved by declaring a
>
private category.
This is the usual workaround.
>
How would one declare a private category. One example
>
I found simple named the category "Private", but this seems to easy /
>
wrong to me.
From the way Objectve-C works, it's not. The basic principle in Objective-C
is that you are able to send any message to any object at any time (you
might end up with an exception, if the object doesn't understand the
message).
You can't change this behaviour by altering the scope of a method
implementation. The only thing you can do about it is to set the visibility
of the method declaration in your code.
>
>
2.) Abstract methods:
>
Is is possible to declare methods / classes as abstract.
Not really I think. You'd use protocols and perhaps empty dummy methods,
that complain when used directly and not via inheritance (during runtime).
>
Conceptually I
>
see that it is possible, but how is it done in practice to prevent
>
instantiation of a class?
By overriding the instantiation method to return nil or to throw an
exception.
>
>
3.) Inheritance of the constructor / class methods
>
Is seems to me that the constructor is inherited as well. Does this
>
mean that inheritance covers class methods (i.e. +) as well ?
>
Yes.
AFAIK these and similar questions have been asked a couple of times before.
You should find more detailed answeres in the archives:
http://cocoa.mamasam.com/
Other readings that could be helpful:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/index.h
tml
http://www.faqs.org/faqs/computer-lang/Objective-C/faq/
Yours,
Joern Salewski
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.