Re: [basic] retain an NSTextView object and update a window
Re: [basic] retain an NSTextView object and update a window
- Subject: Re: [basic] retain an NSTextView object and update a window
- From: Jaime Magiera <email@hidden>
- Date: Thu, 2 Jan 2003 04:29:49 -0500
Ok, I must be doing something wrong. I connected the window's
NSTextView to NSTextView outlets in several controller classes at
once -- just to see what's going on. The following code works fine from
every controller class -- IF it's called from a NIB object (Button,
etc.) or any "awakeFromNib" method:
[speechView setString:@"called from soap responder in the awake from
nib method"];
The same goes for the calling the following method I wrote into the
window's initial controller class:
- (IBAction)speakAndDisplayText:(id)sender
{
NSString *aString = @"Made it to the speak and display";
[sendTextView setBackgroundColor:[NSColor redColor]];
[sendTextView setString:aString];
[sendTextView setNeedsDisplay:YES];
[sendTextView startSpeaking:self];
}
This function works when called in any "awakeFromNib" method in any of
the application classes (with the proper connection made in IB,
thanks). However, it doesn't work when called from within any OTHER
method, in any other class.
I must have the right NSTextView instance to be able to change it in
the "awakeFromNib" calls. What's the difference between that and any
other method in a class?
Totally lost,
Jaime
On Thursday, January 2, 2003, at 12:32 AM, David Rio Vierra wrote:
The second time, you're probably calling those methods on some other
instance of aWindowController. The object you created in Interface
Builder, represented by that blue cube, is one instance of it, and it
is the one with a connection to the NSTextView. If you want other
objects to use that same instance of aWindowController, you'll have to
connect them in IB using an IBOutlet in the other objects..
You generally don't need to retain any user interface elements, other
than windows that will never be used again once closed. .
_______________________________________________
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.