• 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: Asymmetrical behavior in NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Asymmetrical behavior in NSMutableArray


  • Subject: Re: Asymmetrical behavior in NSMutableArray
  • From: Serge Meynard <email@hidden>
  • Date: Thu, 10 Mar 2005 20:45:30 -0500

I find it odd that addObject and removeObject: would behave differently
when it comes to duplicates. It's not a huge concern, since I worked
around the problem (for now anyway) by making sure I remove things
*before* adding them again, and not the other way around. But it's not
what I'd call intuitive behavior.

See also NSSet, NSCountedSet and their mutable counterparts - they may be more what you're looking for.

As I mentioned in my original post, I'm perfectly aware for both NSSet and NSCountedSet. I'm using an NSArray because I need the items to be ordered, and sets don't do that. If NSArray had been symetrical in its add/remove behavior, this problem would not have cropped up.
As it is I worked around the problem, but it's just inelegant to have to move bits of code around from one method to another only because of an implementation detail that's hidden in another class. I'll probably end up recoding some things to avoid the "remove all copies" behavior; if I'm in the mood I might even cook myself up a new "NSOrderedSet" class... Which would be cool to have in general!


_______________________________________________
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


References: 
 >Asymmetrical behavior in NSMutableArray (From: Serge Meynard <email@hidden>)
 >Re: Asymmetrical behavior in NSMutableArray (From: Shawn Erickson <email@hidden>)
 >Re: Asymmetrical behavior in NSMutableArray (From: Serge Meynard <email@hidden>)
 >Re: Asymmetrical behavior in NSMutableArray (From: Guy English <email@hidden>)

  • Prev by Date: Re: NSGLImage doesnt open large images
  • Next by Date: Re: Could not connect the action to target of class
  • Previous by thread: Re: Asymmetrical behavior in NSMutableArray
  • Next by thread: Re: Asymmetrical behavior in NSMutableArray
  • Index(es):
    • Date
    • Thread