Schmidts Katze Posted December 9, 2008 Share Posted December 9, 2008 Hi to all! I'm a Cocoa beginner and I've started programming a document based application in ObjC. This little program has 2 nib files (MyDocument and MainMenu which includes an app controller). I want to pass the document's textData to my app controller which has a method: - (void)processDocData: (NSString *) string { NSLog(@"Hello from AppController!\n"); } In MyDocument, I'm loading the document text into a string: textData = [[documentTextView textStorage] string]; But how can I call processDocData from here? Any ideas welcome. Schmidts Katze Link to comment https://www.insanelymac.com/forum/topic/140221-pass-nsdocument-text-data-to-app-controller/ Share on other sites More sharing options...
Schmidts Katze Posted December 11, 2008 Author Share Posted December 11, 2008 I have'nt found an elegant solution but here's my kludge. I have set up a global variable extern NSString * textData; Now, when I want to "pass" the text of the current document to the app controller, I assign the text to the global string textData = [[documentTextView textStorage] string]; and send processDocData though the responder chain: [[NSApplication sharedApplication] sendAction: @selector(processDocData:) to: nil from : self]; This works but if you have a better idea, please let me know. SK Link to comment https://www.insanelymac.com/forum/topic/140221-pass-nsdocument-text-data-to-app-controller/#findComment-995716 Share on other sites More sharing options...
Recommended Posts