• 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: Indexed Accessors for arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indexed Accessors for arrays


  • Subject: Re: Indexed Accessors for arrays
  • From: Dustin Voss <email@hidden>
  • Date: Thu, 25 Nov 2004 09:30:43 -0800

On 25 Nov, 2004, at 7:51 AM, Ricky Sharp wrote:

I'm ensuring my objects are KVC compliant. Thanks to Kevin Callahan's Accessorizer, this is going very smoothly.

However, I'm trying to figure out what to do with the following iVar:

NSString*	imageNames [IIButtonImageCount];

where IIButtonImageCount is a constant (currently 6). This fixed-sized array stores the names of the images to use for all states I allow for my buttons. If a particular value is nil, that signals that the particular state doesn't have an image in which case it reverts to using some other state. For example, not all my buttons will have "mouseover" images.

But isn't it a case where I cannot create indexed accessors for imageNames as it isn't one of the collection classes (e.g. NSArray)?

Sure you can. The actual data structure doesn't matter, what matters is that there is a defined set of methods the system can call. In this case, you simply have to implement -countOfImageNames and -objectInImageNamesAtIndex:.


And, while I don't currently have ivars like this:

float someAttribute [SomeConstant];

Would that also have to be changed to say an NSArray containing NSNumbers?

This one is the same thing, just make sure that -objectInSomeAttributeAtIndex: returns an NSNumber.


_______________________________________________
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: Indexed Accessors for arrays
      • From: Ricky Sharp <email@hidden>
References: 
 >Indexed Accessors for arrays (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: getting a list of connected displays
  • Next by Date: Re: Indexed Accessors for arrays
  • Previous by thread: Indexed Accessors for arrays
  • Next by thread: Re: Indexed Accessors for arrays
  • Index(es):
    • Date
    • Thread