I have searched for how to correctly do this, but I don't believe I have found my answer. This is my setup:
NSWindowController loads in 2 different NSViewControllers (only one is displayed at a time). When I drop a file onto the NSViewController's view that is loaded, I want to save the path of that file. I can get all of this, but what I want to be able to do now is when I swap to my other NSViewController, I want to pass on this file path to the new NSViewController.
The only solution I have come up with is to post a notification from my NSViewController to the NSWindowController and then initialize the 2nd NSViewController with this data, but it seems rather convoluted. Is there a way that I can just save the data somewhere as a global entity and then access it later from my 2nd NSViewController?
NOTE: The NSViewControllers are being released after they are swapped with the other.
Any insight would be appreciated.
UPDATE: I'm just going to change the application so that both view controllers are in memory at all times. This way I can do as others have suggested and use KVO or other methods.
View controllers are meant for controlling views of model objects. So each of your view controllers must be getting their data from some underlying model object which presumably in your case is the same one. If you don't have that, I suggest you re-engineer your application to the MVC pattern.
When you create your view controllers you can set the representedObject property and store the file name as one of its properties. If your model object is KVO compliant you can even have each view controller observe the file name property of the model object and react to changes when they happen.