FROM : Andre
DATE : Sat Jul 22 20:08:04 2006
Adam R. Maxwell wrote:
>
> On Jul 22, 2006, at 10:29, Andre wrote:
>
>> Ashley Clark wrote:
>>
>>> Check out isEqualToArray: in NSArray.
>> Thanks for the response. Yea, but its only for comparing arrays to
>> arrays.
>>
>> What I was looking for was if all objects in an array are equal to
>> each other.
>> IOW, are each and every object containing the same equivalent
>> value e.g
>> an array of NSNumbers all equalling 21.0 would return YES, else NO
>> if the
>> contents' NSNumber objects varied in their value...
>>
>> (Again, it seems apple hasn't a built-in method for this
>> particular aspect...)
>
> It almost sounds like you want an NSSet (or maybe a CFBag)? If you
> want to stick with array functionality, this might work in a
> category, though (untested):
>
> CFIndex cnt = CFArrayGetCount((CFArrayRef)self);
> return (cnt > 0 && CFArrayGetCountOfValue((CFArrayRef)self,
> CFRangeMake(0, cnt), (void *)[self objectAtIndex:0]) == cnt);
Yea, something like that is what I was looking for, just was hoping
it was already defined somewhere in cocoa. (So I wouldn't have to
maintain it with tests etc.)
Thanks for the code sample. Its basically what I wanted to do.
Many thanks,
Andre
DATE : Sat Jul 22 20:08:04 2006
Adam R. Maxwell wrote:
>
> On Jul 22, 2006, at 10:29, Andre wrote:
>
>> Ashley Clark wrote:
>>
>>> Check out isEqualToArray: in NSArray.
>> Thanks for the response. Yea, but its only for comparing arrays to
>> arrays.
>>
>> What I was looking for was if all objects in an array are equal to
>> each other.
>> IOW, are each and every object containing the same equivalent
>> value e.g
>> an array of NSNumbers all equalling 21.0 would return YES, else NO
>> if the
>> contents' NSNumber objects varied in their value...
>>
>> (Again, it seems apple hasn't a built-in method for this
>> particular aspect...)
>
> It almost sounds like you want an NSSet (or maybe a CFBag)? If you
> want to stick with array functionality, this might work in a
> category, though (untested):
>
> CFIndex cnt = CFArrayGetCount((CFArrayRef)self);
> return (cnt > 0 && CFArrayGetCountOfValue((CFArrayRef)self,
> CFRangeMake(0, cnt), (void *)[self objectAtIndex:0]) == cnt);
Yea, something like that is what I was looking for, just was hoping
it was already defined somewhere in cocoa. (So I wouldn't have to
maintain it with tests etc.)
Thanks for the code sample. Its basically what I wanted to do.
Many thanks,
Andre
| Related mails | Author | Date |
|---|---|---|
| listposter | Jul 22, 17:09 | |
| Ashley Clark | Jul 22, 19:12 | |
| Andre | Jul 22, 19:29 | |
| Adam R. Maxwell | Jul 22, 19:48 | |
| Andre | Jul 22, 20:08 | |
| patrick machielse | Jul 22, 21:25 | |
| Andre | Jul 23, 00:53 | |
| patrick machielse | Jul 23, 01:07 | |
| Andre | Jul 23, 04:14 | |
| Michael Ash | Jul 23, 05:07 |






Cocoa mail archive

