I am creating simple document based app. So far I have implemented NSDocument subclass, which is Document
and NSWindowController subclass, which is ToolbarWindowController
. ToolbarWindowController controlls the toolbar, which has sliders to modify user's opened image.
Where I am having issue right now is applying filters (modifying image) on opened image: I can't figure out how to use opened image as source in ToolbarWindowController
.
F.e. when I open image in Document
I can set it as ViewController
imageView, in makeWindowControllers
:
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
image = [[NSImage alloc] initWithData:data];
return YES;
}
- (void)makeWindowControllers {
NSStoryboard* const storyboard = [NSStoryboard storyboardWithName:@"Main" bundle:nil];
NSWindowController* const windowController = [storyboard instantiateControllerWithIdentifier:@"Document Window Controller"];
[[((ViewController *)[windowController contentViewController]) imageView] setImage:image];
[self addWindowController: windowController];
}
Can I somehow access my ToolbarWindowController
properties/variables and create a NSImage
property there to modify there opened image? Or can I access Document
properties to achieve the same thing? Does it even work that way?
NSWindowController
has a document
property. If everything is hooked up properly, that property will point at the NSDocument
object that owns the NSWindowController
.