Re: NSTextField recieves string but does not display it?
Re: NSTextField recieves string but does not display it?
- Subject: Re: NSTextField recieves string but does not display it?
- From: Quincey Morris <email@hidden>
- Date: Sun, 05 Feb 2012 09:54:33 -0800
On Feb 5, 2012, at 00:18 , Erik Stainsby wrote:
> The web browser instantiates a subclassed WebView which declares & implements:
>
> @interface RSSWebView : WebView
>
> @property (retain) IBOutlet RSSRuleEditorController * ruleEditor;
> - (IBAction) quickSetActionSelector:(id)sender;
> @end
>
> @implementation RSSWebView
>
> @synthesize ruleEditor;
>
> - (IBAction) quickSetActionSelector:(id)sender {
> NSString * nodeSelector = [sender respresentedObject];
> if( nodeSelector != nil) {
> [ruleEditor setActionSelectorStringValue:nodeSelector];
> }
> }
>
> @end
>
> ====
>
> The Rule Editor is a WindowController initialized in the AppDelegate:
>
> - (void) applicationWillFinishLaunching:(NSNotification *)notification {
> NSLog(@"%s- [d] %@", __PRETTY_FUNCTION__, __LINE__, @"");
>
> // this is a secondary window
> editorController = [[RSSRuleEditorController alloc] init];
> [[editorController window] makeKeyAndOrderFront:self];
> }
>
> The RSSWebView ruleEditor is connected to this editorController in IB.
Well, this doesn't look right. You have an outlet in a view that is instantiated from a nib, which you say is connected in IB. Connected to what? The only possibility is that it's connected to something in the nib.
OTOH, you create a window controller in the app delegate. It has no relationship to the nib.
I'm guessing you put a RSSRuleEditorController in the nib for your web view to connect its outlet to, thinking this would be a proxy to the real controller. It isn't. The only proxy objects (standing for objects outside the nib) are File's Owner, Application and First Responder (which isn't exactly an object proxy, though).
If that's what you did, you have two RSSRuleEditorController objects, one from the nib and one that you created yourself, and therefore two windows, and therefore two text fields. Nothing ever showed the window containing the text field you're setting the string into, so you never see that.
Although there are many ways of organizing the relationship between the various objects, I'd suggest the simplest way is the most conventional:
1. Move the web browser window out of the main menu nib and put it in a separate window nib.
2. Subclass NSWindowController and make it File's Owner of the separate browser window nib.
3. Implement 'quickSetActionSelector:' in this window controller, not in the WebView. Get rid of the WebView's RSSRuleEditorController outlet.
4. If the web browser window is supposed to be always open in your app, create the window controller in the app delegate like you do for the secondary window. It would probably make sense to create the secondary window controller first, and pass its pointer to the web browser window controller when you create it. That gives you the linkage you were looking for originally.
Note that I haven't used WebKit, so it may impose requirements that interfere with the conventional use of window controllers, but a cursory glance at the documentation didn't suggest there'd be a problem.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden