• 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: Where is NSList?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where is NSList?


  • Subject: Re: Where is NSList?
  • From: Allan Odgaard <email@hidden>
  • Date: Wed, 28 Jul 2004 00:18:28 +0200

On 27. Jul 2004, at 23:38, Kay Roepke wrote:

each object stored in it, so that each object knows exactly where it is in the container (making for easy deletion, given the object to be deleted).

Well, you can view indices as the iterators for arrays (there are methods like indexOfObject:, removeObjectAtIndex: etc.) and the key for dictionaries (there are methods like removeObjectForKey: etc.).

How do people handle this sort of thing in Cocoa? I'm used to STL's map, list, et al, which use these sorts of iterators.

While there certainly are containers in Cocoa (look at the Foundation References, perhaps you only saw the AppKit documentation?) it is not suited for writing generic code, if this is what you are hinting at. I have tried to solve the problem by writing some STL iterators that iterate the standard containers (NSString, NSArray, NSDictionary, NSSet, NSIndexSet, and NSData IIRC), you can find them at http://www.top-house.dk/~aae0030/cocoastl/ -- there are also back insert iterators. Though basically this is a bridge to STL (or the other way around, as there are also "constructors" from iterator sequences to Cocoa containers, e.g. NSStringFromSequence(first, last), NSDataFromSequence(first, last) etc.).

Mhmhm, NSArray and objectEnumerator will most certainly those that you are looking for.

The limitations with NSEnumerator is that we cannot express ranges with it, we cannot assign to the container through it, we cannot "adapt" the iteration w/o affecting performance, we can only do forward-iteration element-by-element, we cannot copy an enumerator to save the position etc.

That is probably why close to no methods take an NSEnumerator as argument ;)
_______________________________________________
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: Where is NSList?
      • From: Chris Hanson <email@hidden>
References: 
 >Where is NSList? (From: Tim Conkling <email@hidden>)
 >Re: Where is NSList? (From: Kay Roepke <email@hidden>)

  • Prev by Date: Re: Where is NSList?
  • Next by Date: Re: Where is NSList?
  • Previous by thread: Re: Where is NSList?
  • Next by thread: Re: Where is NSList?
  • Index(es):
    • Date
    • Thread