Yes, those result in a message call, though it's a very fast message call. Within your instance methods, however, you can just access the ivar directly, e.g, "connection" without a message call and without "self->connection".

-Jeff


On May 1, 2009, at 11:00 AM, Nick Hristov wrote:

Thank you all for your suggestions. I will use the runloop to wait on
response.

One more comment on self->ivar... I used this approach because using [self connection] or self.connection (they are both the same thing) amount to an
extra message call.

Nick

On Thu, Apr 30, 2009 at 11:09 AM, Jeff Johnson <
publicpost...@lapcatsoftware.com> wrote:

On Apr 30, 2009, at 12:53 AM, Kyle Sluder wrote:

On Thu, Apr 30, 2009 at 1:44 AM, Jeff Johnson
<publicpost...@lapcatsoftware.com> wrote:

On an unrelated note, your use of "self->connection", etc., is
non-standard
and not advised. You should be using direct ivar access "connection", properties "self.connection", or accessor methods "[self connection]".


Sure, `self->connection` is redundant with just plain old
`connection`, but they amount to the same thing. Unless there's some
new-runtime trickery going on that I'm not aware of.

--Kyle Sluder


It amounts to the same thing, but it's a bad habit to get into. It's
redundant, as you say, for an object's own instance variables. And you shouldn't be trying to directly access the instance variables of other objects. According to the documentation, "Marking instance variables @public defeats the ability of an object to hide its data. It runs counter to a fundamental principle of object-oriented programming—the encapsulation of data within objects where it’s protected from view and inadvertent error.
Public instance variables should therefore be avoided except in
extraordinary cases." Thus, except in extraordinary cases, there's no reason
to use the "object->ivar" syntax.

-Jeff

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to