• 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: Collection classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Collection classes


  • Subject: Re: Collection classes
  • From: Alexander Spohr <email@hidden>
  • Date: Thu, 8 Jan 2004 15:37:07 +0100

timothy,

I am implementing a table data source. I have a class (Foo) that has an
instance attribute (bar) of type NSMutableSet that I want to have the
table display. The contract of bar is that it not allow duplicates, so it
HAS to be a NSSet*, as that is the only collection that enforces that
contract. The Cocoa data sources in Cocoa want collections that are
indexable, and I understand why.

use NSMutableArray and check for containsObject: before you insert.

i rember apple having a private method called -(BOOL)addObjectIfAbsent: that was not in the headers of NSMutableArray. so before you add such a method as a category, try to just create a header for it. if you can use it fine (it's still in there somewhere) if you get selectorNotRecognized just implement it yourself and you can use NSMutableArray as an indexable list with unique entries.

atze
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Collection classes
      • From: "Timothy Reaves" <email@hidden>
References: 
 >Collection classes (From: T Reaves <email@hidden>)
 >Re: Collection classes (From: Todd Blanchard <email@hidden>)

  • Prev by Date: Re: Message.framework bugs?
  • Next by Date: Re: Thinking about shareware prices... (was a question about NSDate inside userDefaults)
  • Previous by thread: Re: Collection classes
  • Next by thread: Re: Collection classes
  • Index(es):
    • Date
    • Thread