Some confusion on memory management
Some confusion on memory management
- Subject: Some confusion on memory management
- From: Mike Abdullah <email@hidden>
- Date: Fri, 20 Jan 2006 15:09:04 +0000
I am still getting to grips with Cocoa, and would like to ask a
question on memory management that will hopefully clear things up for
me.
I have my subclass of NSDocument, and my document window contains a
single text view.
The idea, is that every time, the text in the text view is changed by
the user, my NSDocument will change its internal value accordingly.
I have the delegate system for the text view set up fine, so that
when the text does change, I carry out the command:
[self setMyString: newString];
So, in my class there are 2 methods: setMyString and myString. The
thing I don't fully understand is how to properly get the internal
value of myString to be remembered throughout the life of the
NSDocument. In my header file I have placed:
NSString *myString;
And in the two methods I have this:
- (void)setMyString:(NSString *)newString
{
myString = newString;
}
-(NSString *)myString
{
return myString;
}
However, I am sure this is not entirely correct, since it seems that
after a while, the NSDocument "forgets" the value of myString, so I
am sure that I have the memory management wrong! Also, should I
really be using NSString? Would I be better off with NSMutableString?
Please help!
Mike.
_______________________________________________
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