• 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: NSArray or MutableArray Null/NIL placeholder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray or MutableArray Null/NIL placeholder


  • Subject: Re: NSArray or MutableArray Null/NIL placeholder
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 30 May 2007 16:08:15 +0100

It sounds to me like NSArray is not the real solution here. Since you have a fixed number of objects and want to keep objects in their correct place, I suspect you would be better off subclassing NSObject to offer the exact model behaviour required. Of course, you could always use NSMutableArray internally…

Mike.

On 30 May 2007, at 15:48, Vince Ackerman wrote:

I need to have an array of 16 (id) objects. When I create them, I want to keep them in a specific order at a specific index in the array. If I dispose of the object, I want the index in the array to be empty, not back filled by the next object as suggested by the docs. I want to be able to test the index to see if any object is currently at that index. My question is this: Somewhere I read that you can't insert a nil object into NSArray? What would I use as a placeholder that would indicate an empty slot in the array? Would null work?


Searching the docs for NSMutableArray doesn't seem to give me an answer. All the methods seem to avoid leaving an empty index.


Also, do I need to retain/release an object when inserting/deleting the object in an Array, or does NSArray do this automatically?

Maybe I'm misunderstanding nil/null.

Thanks in advance for any help.


Vince

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mikeabdullah.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSArray or MutableArray Null/NIL placeholder (From: Vince Ackerman <email@hidden>)

  • Prev by Date: Re: NSArray or MutableArray Null/NIL placeholder
  • Next by Date: How can I reset QTMovieView contents?
  • Previous by thread: Re: NSArray or MutableArray Null/NIL placeholder
  • Next by thread: How can I reset QTMovieView contents?
  • Index(es):
    • Date
    • Thread