Skip navigation.
 
mlRe: Indexed Accessors for arrays
FROM : Ricky Sharp
DATE : Thu Nov 25 18:47:47 2004

On Nov 25, 2004, at 11:30 AM, Dustin Voss wrote:

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


You know, I feel a little silly for having asked this :)

I don't know why I was assuming that the implementation had to use a
collection object.  You're correct in stating that it's having those
APIs that matters and not how those APIs are implemented.

Thanks,
___________________________________________________________
Ricky A. Sharp        mailto:<email_removed>
Instant Interactive(tm)  http://www.instantinteractive.com

Related mailsAuthorDate
mlIndexed Accessors for arrays Ricky Sharp Nov 25, 16:51
mlRe: Indexed Accessors for arrays Dustin Voss Nov 25, 18:30
mlRe: Indexed Accessors for arrays Ricky Sharp Nov 25, 18:47
mlRe: Indexed Accessors for arrays mmalcolm crawford Nov 26, 00:37