• 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: Accessor method idioms...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor method idioms...


  • Subject: Re: Accessor method idioms...
  • From: John Brownlow <email@hidden>
  • Date: Thu, 24 Mar 2005 11:53:10 -0500

I've tried writing like this but it always starts to feel redundant, an unnecessary layer of indirection. Maybe there are circumstances where it's helpful but... I haven't found them.

[[self things] objectAtIndex: index]

Just seems way more transparent than:

objectInThingsAtIndex: index

at least when 'things' is a built-in type like NSArray, anyway

I guess if you are actually implementing some kind of new-fangled way of obtaining the object at a particular index it makes sense... for example, I have an array of pages in a script, which starts at 0, while the page numbering the user sees starts at 1. So I have an accessor something like

- (GLPage *)pageAtPageNumber: (int) pageNumber
{
	return [[self pages] objectAtIndex: pageNumber-1];
}

In this case it makes sense to me to use a custom accessor but it seems to obscure things in the vanilla case.


On Mar 24, 2005, at 11:15 AM, Mike Ferris wrote:

- (id)objectInThingsAtIndex:(unsigned)theIndex {

--
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


  • Follow-Ups:
    • Re: Accessor method idioms...
      • From: Mike Ferris <email@hidden>
    • Re: Accessor method idioms...
      • From: "M. Uli Kusterer" <email@hidden>
References: 
 >Accessor method idioms... (From: Mike Ferris <email@hidden>)

  • Prev by Date: How to develop databases
  • Next by Date: NSMenu conundrum
  • Previous by thread: Accessor method idioms...
  • Next by thread: Re: Accessor method idioms...
  • Index(es):
    • Date
    • Thread