Re: Scope in an interface?
Re: Scope in an interface?
- Subject: Re: Scope in an interface?
- From: Uli Kusterer <email@hidden>
- Date: Mon, 26 May 2008 00:14:10 +0200
- Resent-date: Mon, 26 May 2008 01:14:22 +0200
- Resent-from: Uli Kusterer <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: Cocoa Cocoa-Dev <email@hidden>
Am 25.05.2008 um 09:41 schrieb Jens Alfke:
* Calling any method on a NULL object pointer doesn't crash, and
doesn't call any code; instead, it's a no-op. This is actually
extremely useful and can be taken advantage of to make your code
much more concise by eliminating a lot of pointer checks.
One warning: For methods that have a return value, only certain return
types are supported (which will in that case return 0). So read up on
the details if you want to send a message to NIL.
* Method dispatch is more dynamic; it's based on the name of the
method (the selector) not a vtable offset. This means that even if
you don't know the class of an object at compile time, you can still
call methods on it. For example, given a declaration "id foo", you
can call [foo doSomething] and it will successfully call a method
named doSomething, if foo has a base class that implements it, no
matter what the class hierarchy looks like.
This is why ObjC supports "duck typing". Great tool in the tool belt.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden