• 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
Some confusion on memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Some confusion on memory management
      • From: Jeff Gilbert <email@hidden>
    • Re: Some confusion on memory management
      • From: Jeff LaMarche <email@hidden>
    • Re: Some confusion on memory management
      • From: Stephane <email@hidden>
  • Prev by Date: Re: cocoa interact with finder
  • Next by Date: Re: Some confusion on memory management
  • Previous by thread: Re: Cocoa-dev Digest, Vol 3, Issue 91
  • Next by thread: Re: Some confusion on memory management
  • Index(es):
    • Date
    • Thread