Re: NSTextView and NSMutableArray
Re: NSTextView and NSMutableArray
- Subject: Re: NSTextView and NSMutableArray
- From: j o a r <email@hidden>
- Date: Tue, 20 May 2003 13:33:50 +0200
On Tuesday, May 20, 2003, at 12:48 Europe/Stockholm, Peter Karlsson
wrote:
I can't figure out how to store a NSTextView to a NSMutableArray and
get it back from the NSMutableArray to the NSTextView again. Can
someone point me in the right direction please?
You mean "...how to store [the contents of] a NSTextView..." right?
Something like this:
// Text view with some text
[myTextView setString: @"any string"];
// Store the string to an array
NSMutableArray *arr = [NSMutableArray arrayWithObject: [myTextView
string]];
// Something happens to the text in the text view
[myTextView setString: @"some other string"];
// Restore text from array to text view
[myTextView setString: [arr objectAtIndex: 0]];
If you want to store the formatted string, and not just the series of
characters, use [[[myTextView textStorage] copy] autorelease] instead
of [myTextView string], or something similar.
j o a r
_______________________________________________
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.