Johnny Lundy wrote:

I imagine this is a very dumb question, but I am perplexed.

NSArray says you can change the values of elements, but not add/
subtract/replace elements.

Right. Meaning if a contained object it mutable, you can mutate it and the NSArray won't care.

Let's say I have an NSArray @"Tom", @"Dick", @"Harry", nil

And I want to change Tom and Dick to Mutt and Jeff.

Is my only option to make it a MutableArray and use
replaceObjectAtIndex:0 and :1 with @"Mutt" and @"Jeff"?

Only? No, but that'd be the sensible, straightforward way (presuming those strings are not mutable).

Is there a way just to set the value of an array element without
replacing it?

The question's not really meaningful because there's no such concept as an 'unset' element in an NSArray. If an array has some content at index N it also has content in every index in [0,N-1]. So there's no distinction between setting the value at index N and replacing the value at index N.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to