• 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: [newbie] NSString code so it won't leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] NSString code so it won't leak


  • Subject: Re: [newbie] NSString code so it won't leak
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 10 Sep 2002 20:42:22 +0200

On Tuesday, September 10, 2002, at 03:58 , Dean Davis wrote:

NSString *string1,*myString

string1 = [myString stringToIndex:41];
myString = [myString stringFromIndex:41];

This works but leaks.

It not only works; also, it does not leak. Read memory management, focus on autoreleasing.

myString = [myString2 stringFromString:myString2];
// or? myString = [myString2 copy];
[myString2 release];

This would crash, on the other hand.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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.

  • Follow-Ups:
    • Re: [newbie] NSString code so it won't leak
      • From: Dean Davis <email@hidden>
References: 
 >[newbie] NSString code so it won't leak (From: Dean Davis <email@hidden>)

  • Prev by Date: Re: Changing extension etc for doc-based app
  • Next by Date: Re: cocoa-dev digest, Vol 2 #1226 - 17 msgs
  • Previous by thread: [newbie] NSString code so it won't leak
  • Next by thread: Re: [newbie] NSString code so it won't leak
  • Index(es):
    • Date
    • Thread