Re: Cocoa Style Question
Re: Cocoa Style Question
- Subject: Re: Cocoa Style Question
- From: John Brownlow <email@hidden>
- Date: Thu, 31 Mar 2005 13:27:58 -0500
In my opinion, whichever is more readable.
In this case the second.
But the readability is compromised by using shorthand iVar names like
'nc'. 'defaultNotificationCenter' is way better.
In terms of execution time I think the difference is nil, or literally
a few nanoseconds. Often it will turn out to be faster because you will
re-use the variable further down in the code and save a messaging
round.
I've lost count of the number of times I've written a long line like
your first, thinking it was easier, only to find out an hour later that
I had to do the same thing several times, so went back and broke it
down into assignments and variables.
On Mar 31, 2005, at 1:19 PM, Adam wrote:
What is considered good cocoa style? I am sometimes tempted to be
efficient and code like:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sendCommandToSocket:)
name:@"AGFIBSSendCommandToSocket" object:nil];
Is it better to be more clear like and break things down:
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(sendCommandToSocket:)
name:@"AGFIBSSendCommandToSocket" object:nil];
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
John Brownlow
Deep Fried Films, Inc
http://www.johnbrownlow.com
http://www.pinkheadedbug.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden