FROM : Kane Dijkman
DATE : Wed Apr 13 18:56:07 2005
I am working on my first cocoa app and have recently gotten my head
around bindings (for the most part). Now I am trying to create a new
window and use it with bindings. I am not sure if this problem is
because of how I am opening the window (which is probably wrong) or
something I am missing with bindings. (I think it is the window issue)
Here is what I am trying to do...
This is a non-document based app.
I have a Controller that works with the main nib/window. In it there is
a list of files. When a user selects one and hits the "edit" button a
new window is supposed to open up so the user can edit the values in a
text file that the list item points to.
I want the edit window to have its own controller. So I created one
called list editor controller. When the edit button is pressed this
code is run:
ListEditorController * lec = [[ListEditorController alloc] init];
NSString * listPath = [[self getPreference:@"pathToLists"]
stringByAppendingPathComponent:[[self getSelectedListNames]
objectAtIndex:0]];
[lec openList:listPath];
[lec release];
This calls the ListEditorController object which has the following in
its init file to open a new window.
if (listEditorWindow == nil )
{
if (![NSBundle loadNibNamed:@"ListEditor.nib" owner:self])
{
NSLog(@"Load of ListEditor.nib failed");
return;
}
}
[listEditorWindow makeKeyAndOrderFront:nil];
So far, so good.
In IB for the ListEditor.nib I have the File's Owner as the Controller.
and under NSResponder:NSWindowController I have the
ListEditorController.
With using bindings or not I am having the same question:
Without bindings: How can I create an Outlet in the
ListEditorController and connect it to the NSTextView i have in the new
window? I tried instantiating the ListEditorController but once I do I
get an error and the app does not run. When I try to connect the
NSTextView to the outlet I created in ListEditorController I can not,
because all I see are the Controller values.
For bindings: I am not even sure exactly what to ask... but I think it
what I want is to create an NSObjectController and bind it to a
variable in ListEditorController, but as with the non binding method, I
am not able to see any of the ListEditorController variables.
So, in summation I am trying to have a second controller in this
application that is instantiated and used with a separate nib/window.
While I could create all the code and have it work in the main
controller I want to avoid this since that would make the Controller
file really big by the time everything is done.
Is the approach I am using even correct? Am I creating the
ListEditorController and opening the window properly? In the books I
have and online examples I have seen all I ever see are new windows
being created that are controlled by the main controller. So am I
totally off in my thinking that a separate controller for a window that
has a specific function is the best way to go?
Thanks,
Kane
DATE : Wed Apr 13 18:56:07 2005
I am working on my first cocoa app and have recently gotten my head
around bindings (for the most part). Now I am trying to create a new
window and use it with bindings. I am not sure if this problem is
because of how I am opening the window (which is probably wrong) or
something I am missing with bindings. (I think it is the window issue)
Here is what I am trying to do...
This is a non-document based app.
I have a Controller that works with the main nib/window. In it there is
a list of files. When a user selects one and hits the "edit" button a
new window is supposed to open up so the user can edit the values in a
text file that the list item points to.
I want the edit window to have its own controller. So I created one
called list editor controller. When the edit button is pressed this
code is run:
ListEditorController * lec = [[ListEditorController alloc] init];
NSString * listPath = [[self getPreference:@"pathToLists"]
stringByAppendingPathComponent:[[self getSelectedListNames]
objectAtIndex:0]];
[lec openList:listPath];
[lec release];
This calls the ListEditorController object which has the following in
its init file to open a new window.
if (listEditorWindow == nil )
{
if (![NSBundle loadNibNamed:@"ListEditor.nib" owner:self])
{
NSLog(@"Load of ListEditor.nib failed");
return;
}
}
[listEditorWindow makeKeyAndOrderFront:nil];
So far, so good.
In IB for the ListEditor.nib I have the File's Owner as the Controller.
and under NSResponder:NSWindowController I have the
ListEditorController.
With using bindings or not I am having the same question:
Without bindings: How can I create an Outlet in the
ListEditorController and connect it to the NSTextView i have in the new
window? I tried instantiating the ListEditorController but once I do I
get an error and the app does not run. When I try to connect the
NSTextView to the outlet I created in ListEditorController I can not,
because all I see are the Controller values.
For bindings: I am not even sure exactly what to ask... but I think it
what I want is to create an NSObjectController and bind it to a
variable in ListEditorController, but as with the non binding method, I
am not able to see any of the ListEditorController variables.
So, in summation I am trying to have a second controller in this
application that is instantiated and used with a separate nib/window.
While I could create all the code and have it work in the main
controller I want to avoid this since that would make the Controller
file really big by the time everything is done.
Is the approach I am using even correct? Am I creating the
ListEditorController and opening the window properly? In the books I
have and online examples I have seen all I ever see are new windows
being created that are controlled by the main controller. So am I
totally off in my thinking that a separate controller for a window that
has a specific function is the best way to go?
Thanks,
Kane
| Related mails | Author | Date |
|---|---|---|
| Kane Dijkman | Apr 13, 18:56 | |
| Jonathon Mah | Apr 13, 19:37 |






Cocoa mail archive

