Jump to content
2 posts in this topic

Recommended Posts

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

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

×
×
  • Create New...