• 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
Setting the value of an array element
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting the value of an array element


  • Subject: Setting the value of an array element
  • From: Johnny Lundy <email@hidden>
  • Date: Thu, 17 Apr 2008 12:15:23 -0400

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.

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"?

My confusion is that there is no setValue:forIndex:. There is only setValue: forKey: , but arrays do not have keys.

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


Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Setting the value of an array element
      • From: "Sherm Pendley" <email@hidden>
    • Re: Setting the value of an array element
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: -charactersIgnoringModifiers and the shift key
  • Next by Date: Re: -charactersIgnoringModifiers and the shift key
  • Previous by thread: Re: -charactersIgnoringModifiers and the shift key
  • Next by thread: Re: Setting the value of an array element
  • Index(es):
    • Date
    • Thread