Re: New document with data from Services?
Re: New document with data from Services?
- Subject: Re: New document with data from Services?
- From: Michael McCracken <email@hidden>
- Date: Sun, 4 Aug 2002 12:40:03 -0700
Here's my guess, assuming that you use loadDataRepresentation to
populate your model class: get the selected string from the pasteboard,
convert it into an NSData instance, then call
- (BOOL)loadDataRepresentation:(NSData *)docData ofType:(NSString
*)docType (NSDocument) on a new NSDocument.
Use NSDocumentController's makeUntitledDocumentOfType: method, which
returns the NSDocument that it creates, to get a pointer to the new doc,
instead of newDocument, which is a void function.
hope this helps.
On Saturday, August 3, 2002, at 08:27 PM, cocoa-dev-
email@hidden wrote:
Message: 9
Date: Sat, 3 Aug 2002 17:40:56 -0700
To: email@hidden
From: David Sinclair <email@hidden>
Subject: New document with data from Services?
I'm read the documentation, and searched on mamasam.com, but can't
find an answer to the following.
I have a NSDocument-based application, and am trying to add a Service
to it to open a new document with the selected text. What I can't
figure out is how to both call newDocument: to open the document
window, and insert the text into the new text view.
I can call newDocument: via the following from the Services handler
method, but how do I then get the data into the text view?
[[NSDocumentController sharedDocumentController] newDocument:self];
Or I can create a new instance of the window controller and insert
the text, but how do I do the setup stuff that newDocument: does?
I have to believe that there is an easy way to do this that I'm
missing. Any pointers would be appreciated!
Also, while I'm at it: it does the right thing when the app is
already running, but if the Service action launches the app, it
creates a second new document (in addition to the usual one on
launch). Is there any way I can just use the default untitled
document in this case?
--
David Sinclair - email@hidden
http://www.dejal.com/
--
Michael McCracken
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.