• 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: copying nsstrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copying nsstrings


  • Subject: Re: copying nsstrings
  • From: j o a r <email@hidden>
  • Date: Sat, 29 Nov 2003 12:07:59 +0100

On 2003-11-29, at 07.33, Tavis wrote:

> I have a method that keeps updating a string and eventually It crashes
> with a bad access. Do I need to free the NSstring somehow?
> My method is like this:
>
> NSString *backupString, *newString;
>
> - (IBAction) updateString:(id)dummy
> {
> backupString = [newString copy];
> }
>
> After I call updateString a few times, it crashes.

What is "backupString" and "newString" here? Global variables? When are
they assigned values? What do you do with the "dummy" parameter, it's
not used in the code snipped you show above? What happens with the old
object assigned to the "backupString" variable when you reassign it
with the copy of "newString"?

You need to read about memory management rules for Cocoa. There are
plenty of information in the Apple-provided documentation, and lots of
questions and answers about this in the list archives and the Cococa
developement sites around the web.

<http://cocoa.mamasam.com/>

j o a r

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >copying nsstrings (From: Tavis <email@hidden>)

  • Prev by Date: NSURLs and timeouts
  • Next by Date: Re: unique ids
  • Previous by thread: copying nsstrings
  • Next by thread: unique ids
  • Index(es):
    • Date
    • Thread