Re: reassignment using convenience methods
Re: reassignment using convenience methods
- Subject: Re: reassignment using convenience methods
- From: Jonathan Jackel <email@hidden>
- Date: Sun, 5 Oct 2003 22:06:12 -0400
Yes, it's fine.
Remember, myString is just a reference to an object -- it isn't the
object. When you point myString at another object, you haven't changed
anything about how Cocoa will manage your memory. Even though YOU
don't have a way of easily getting at the first object, the autorelease
pool does. It has a reference to that object and will send it a
release message at the appropriate time.
Of course, you don't want to do this with an object you are responsible
for releasing. The object hangs around and you won't have any way to
send it a release message, so you'll leak.
Jonathan
On Sunday, October 5, 2003, at 09:38 PM, Robert Borsuk wrote:
Hi,
I've read through a couple of a couple of the Memory management
articles (stepwise - oreilly) and I haven't seen anything about the
following:
NSString *myString;
myString=[NSString stringWithString:@"first assigned"];
//do some stuff
myString=[NSString stringWithString:@"reassign to another string"];
Is reassigning via convenience methods , in the same method, okay?
Thanks
Rob
Rob Borsuk
email: email@hidden
Colourfull Creations
Web: http://www.colourfull.com
_______________________________________________
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.
_______________________________________________
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.