• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Style Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Style Question


  • Subject: Re: Cocoa Style Question
  • From: "Mike R. Manzano" <email@hidden>
  • Date: Thu, 31 Mar 2005 10:28:58 -0800

I can read either of them. The first one is actually more readable to me since my mind blocks the phrase "[NSNotificationCenter defaultCenter]" together as a single entity since I'm so use to seeing it. In the second one, the only thing tying the two lines together is "nc", which I have to visually hunt for. If I were to write it, it would look like this:

[ [NSNotificationCenter defaultCenter]
			addObserver:self
			selector:@selector(sendCommandToSocket:)
			name:@"AGFIBSSendCommandToSocket"
			object:nil 							] ;




On Mar 31, 2005, at 10:19 AM, 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: This email sent to email@hidden
  • Follow-Ups:
    • Re: Cocoa Style Question
      • From: Shawn Erickson <email@hidden>
References: 
 >Cocoa Style Question (From: Adam <email@hidden>)

  • Prev by Date: Re: Cocoa Style Question
  • Next by Date: Re: Cocoa Style Question
  • Previous by thread: Re: Cocoa Style Question
  • Next by thread: Re: Cocoa Style Question
  • Index(es):
    • Date
    • Thread