RE: memory management
RE: memory management
- Subject: RE: memory management
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Mon, 14 Apr 2003 17:27:45 -0400
If you didn't retain it or create it then you don't release it. Who is
responsible for releasing the string? Not you! So do nothing.
This is the beauty of retain/release. You don't need to know that the text
fields are retaining the string. It's up to the text fields to release the
strings if they retain them.
Jonathan
>
-----Original Message-----
>
From: email@hidden
>
[mailto:email@hidden]On Behalf Of Uwe Schlosser
>
Sent: Monday, April 14, 2003 2:27 PM
>
To: email@hidden
>
Subject: memory management
>
>
>
I use the following code segment in a document based cocoa application:
>
>
feldname1= [NSString
>
stringWithFormat:NSLocalizedString(@"Field1",nil)]; // NSString
>
*feldname1;
>
[boxArray insertObject:feldname1 atIndex:1];
>
// NSMutableArray
>
*boxArray;
>
>
after this line the "retaincount" of feldname1 is two (including the
>
autorelease of the first line)
>
>
I know that I am responsible for the memory management of feldname1 for
>
these lines
>
>
now I set three text fields in the user interface created with
>
Interface Builder:
>
[Feldname1Doc setStringValue:feldname1]; // IBOutlet NSTextField
>
*Feldname1Doc;
>
[Feldname1Add setStringValue:feldname1]; // IBOutlet NSTextField
>
*Feldname1Add;
>
[Feldname1Pref setStringValue:feldname1]; // IBOutlet NSTextField
>
*Feldname1Pref;
>
>
after this the "retaincount" of feldname1 is 5
>
>
>
now my question: when the document is closed, who is responsible of
>
decreasing the retaincount of feldname1 for the last three lines ? Is
>
this done automatically or must this done in the dealloc subroutine?
>
>
Thanks for any Help
>
>
Uwe
>
_______________________________________________
>
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.