Memory management question (passing objects to method)
Memory management question (passing objects to method)
- Subject: Memory management question (passing objects to method)
- From: <email@hidden>
- Date: Tue, 1 Mar 2005 6:09:49 +0000
I have a question about memory management and passing objects created in one method to another method. When/where do I release these objects? Example, if you will...
- (void)doSomething
{
NSString* test = @"test";
[self doSomethingElse:test];
}
- (void)doSomethingElse:(NSString*)test
{
NSLog(@"%@", test);
}
Now, these are my questions, and I apologize if they're rather basic, I tried searching for an answer and didn't really find one. When "test" is passed to doSomethingElse, should I retain it in doSomethingElse, and then release it before the method ends? Or should I release it in doSomething after it is passed to doSomethingElse, retain it in doSomethingElse and release it when doSomethingElse ends?
I'm curious about this because I don't know, and I want to make sure I practice good memory management. Thanks for any and all help. Feel free to link to me past posts/articles that have already answered this.
James
_______________________________________________
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