Re: Finding out if an NSArray's contents are all equal
Re: Finding out if an NSArray's contents are all equal
- Subject: Re: Finding out if an NSArray's contents are all equal
- From: Andre <email@hidden>
- Date: Sat, 22 Jul 2006 19:14:08 -0700
patrick machielse wrote:
Op 23-jul-2006, om 00:53 heeft Andre het volgende geschreven:
patrick machielse wrote:
@implementation NSArray (IdenticalObjects)
- (BOOL)allObjectsIdentical
{
return [[NSSet setWithArray:self] count] == 2;
}
@end
This should of course have read:
return [[NSSet setWithArray:self] count] == 1; // _ONE_!
Yea, I noticed that one.
A better/nicer/more general idea would be to use:
- (unsigned)numberOfDistinctObjects
{
return [[NSSet setWithArray:self] count];
}
I think thats a good complementary method to the first one.
Thanks alot, and I'll be sure to file a bug report about this as well.
Hopefully apple would find it useful enough to add to NSArray
Andre
_______________________________________________
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