Think about the Finder.  You click on a file, get a preview.  If you like it 
you can open it.  That's what I'm driving at.  You click on a row in a 
tableView, you get a preview (the opening is in code, I'm storing an index of 
file references in a different NSDocument) and if you like it you open up in a 
new window.  The difference here is you can edit the file in preview.

I'll try your code.  Thanks for the reply.

On Apr 30, 2010, at 1:17 PM, Quincey Morris wrote:

> On Apr 30, 2010, at 08:56, Brad Stone wrote:
> 
>> I want to open NSPersistentDocuments and load them into the same window one 
>> at a time.
> 
> Excuse the soapbox, but you do realize that from the outside looking in, this 
> *seems* like a terrible idea? If your documents really are documents in the 
> user interface sense, then what's the reason for inventing a new 
> document-handling metaphor for users? If they're not really documents, then 
> why try to shoehorn them into the NSDocument metaphor?
> 
> Keep in mind that Core Data persistent stores don't really fit the standard 
> document metaphor very well, so that NSPersistentDocument is already a little 
> bit broken. (Ask the people who've had trouble with Save As, for example.) 
> Piling on another layer of metaphorical abuse seems like a prescription for 
> great pain. But anyway ...
> 
>> - (IBAction)newBookTwo:(id)sender {
>>      NSDocumentController *dc = [NSDocumentController 
>> sharedDocumentController];
>>      NSURL *url = [NSURL fileURLWithPath:[@"~/Desktop/File 2.binary" 
>> stringByExpandingTildeInPath]];
>> 
>>      NSError *error;
>>      MainWindowDocument *thisDoc = [dc openDocumentWithContentsOfURL:url 
>> display:NO error:&error];
>> 
>>      [self setDocument:thisDoc];     
>>      [self setManagedObjectContext:[thisDoc managedObjectContext]];
>> }
> 
> Here's what I'd try (apologies if you've tried this already; all typed in 
> mail):
> 
> 1. Create a global variable:
> 
>       MyWindowController* recycledWindowController = nil;
> 
> 2. In the window controller:
> 
> - (IBAction)newBookTwo:(id)sender {
>       NSDocumentController *dc = [NSDocumentController 
> sharedDocumentController];
>       NSURL *url = [NSURL fileURLWithPath:[@"~/Desktop/File 2.binary" 
> stringByExpandingTildeInPath]];
> 
>       recycledWindowController = self;
>       [self.document removeWindowController: self];
> 
>       NSError *error;
>       MainWindowDocument *thisDoc = [dc openDocumentWithContentsOfURL:url 
> display:NO error:&error];
> }
> 
> 3. In the document:
> 
> - (void) makeWindowControllers {
>       if (! recycledWindowController) {
>               recycledWindowController = ... // create a new window controller
>               recycledWindowController.shouldCloseDocument = YES;
>       }
>       [self addWindowController: recycledWindowController];
>       [recycledWindowController noteChangedDocument]; // or send a 
> notification, or have the window controller KVO-observe its own 'document' 
> property
>       recycledWindowController = nil;
> }
> 
> Something like that.
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to