• 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: how to change an NSArray value without release ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to change an NSArray value without release ?


  • Subject: Re: how to change an NSArray value without release ?
  • From: James Spencer <email@hidden>
  • Date: Sun, 13 Nov 2005 19:05:28 -0600


On Nov 13, 2005, at 6:47 PM, Sebosac wrote:

hello,

how can i change the value of an NSArray element without the pointed object was released ?

thanks in advance.


Assuming that what you are doing is calling one of NSMutableArray's replaceObject... methods, simply send a retain message to the original element before doing the replace. You will, of course, also have to keep a reference to it or you will simply leak. E.g.:


oldElement = [myArray objectAtIndex:index];
[oldElement retain]; // remember you are responsible for releasing oldElement at some point
[myArray replaceObjectAtIndex:index withObject:newElement]l;



James P. Spencer Rochester, MN

email@hidden

"Badges??  We don't need no stinkin badges!"

_______________________________________________
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: 
 >how to change an NSArray value without release ? (From: Sebosac <email@hidden>)

  • Prev by Date: how to change an NSArray value without release ?
  • Next by Date: Finding if application launched due to document open?
  • Previous by thread: how to change an NSArray value without release ?
  • Next by thread: Finding if application launched due to document open?
  • Index(es):
    • Date
    • Thread