• 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: Finding out if an NSArray's contents are all equal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding out if an NSArray's contents are all equal


  • Subject: Re: Finding out if an NSArray's contents are all equal
  • From: patrick machielse <email@hidden>
  • Date: Sun, 23 Jul 2006 01:07:38 +0200

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

A better/nicer/more general idea would be to use:

- (unsigned)numberOfDistinctObjects
{
    return [[NSSet setWithArray:self] count];
}

patrick
_______________________________________________
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: Re: Finding out if an NSArray's contents are all equal
      • From: "Michael Ash" <email@hidden>
    • Re: Finding out if an NSArray's contents are all equal
      • From: Andre <email@hidden>
References: 
 >Re: Finding out if an NSArray's contents are all equal (From: patrick machielse <email@hidden>)
 >Re: Finding out if an NSArray's contents are all equal (From: Andre <email@hidden>)

  • Prev by Date: Re: Finding out if an NSArray's contents are all equal
  • Next by Date: Re: -stringValue on NSTextfield does not reflect actual contents
  • Previous by thread: Re: Finding out if an NSArray's contents are all equal
  • Next by thread: Re: Finding out if an NSArray's contents are all equal
  • Index(es):
    • Date
    • Thread