MyDocument and AppController problem
MyDocument and AppController problem
- Subject: MyDocument and AppController problem
- From: Michael Swan <email@hidden>
- Date: Fri, 26 May 2006 17:41:59 -0400
I have a document based project I am working on that uses an
AppController object and MyDocument objects.
The nib for MyDocument has an NSTableView inside an NSScrollView as
well as two NSButton objects.
The nib for AppController has more interface elements including some
NSTextField objects.
When the app starts AppController gets a pointer to the
NSDocumentController
docController = [NSDocumentController sharedDocumentController];
I then use this pointer in various calls to get the front document,
such as:
[[[docController documents] objectAtIndex:0] playNextCue];
When MyDocument gets init I get a pointer to AppController
appController = [NSApp delegate];
I then use this pointer for various tasks for example in - (void)
tableViewSelectionDidChange:(NSNotification *)notification I use this
call to update one of the NSTextField objects in AppController's nib.
[appController setNextCue:[nextCue cueNumber]];
When MyDocument calls AppController the NSTextFlied objects get
updated correctly, clicking on a table row always causes the
upComingCue field to be set to the correct value. However when
AppController calls MyDocument to do something the call makes it
through as proven by NSLog but anything that depends on an IBOutlet
fails.
I stepped through in the debugger and when AppController calls
MyDocument none of the IBOutlet objects have a value (they all read
0x0). When I add a button to the MyDocument nib and call the same
function it works.
It is obvious to me that for some reason the outlets in MyDocument
only have values when the window is the key window while the outlets
in AppController's nib always have values.
I have managed to get the document window to the front with [self
showWindows]; and [[[[self windowControllers] objectAtIndex:0]
window] makeKeyAndOrderFront:self]; but the outlets still have no
value I even tried usleep(1000); to see if that would help to no avail.
So my question is what am I doing wrong? I'm still fairly new at this
so I'm sure I missed something stupid but I have run out of ideas.
BTW this is going to be freeware that I am working on for fun. I can
include more code if needed I just didn't want to send out a huge email.
Thanks,
Mike Swan
Lighting Technician
http://web.mac.com/michaelswan
"As human beings our greatness lies not so much in being able to
remake the world... as being able to remake ourselves" - Gandhi
_______________________________________________
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