• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Opening persistent data store
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening persistent data store


  • Subject: Re: Opening persistent data store
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 8 Nov 2008 23:12:02 -0800

I'm not sure I entirely understand, but I'll give this a shot ...

On Nov 8, 2008, at 19:49, John Velman wrote:

Now, to open the database I use the File -> Open menu, connected to a
method findDatabase in the "first responder" of the NIB. This falls
through to MyDocument, which implements that method, following along more
or less with Hillgass, third edition, page 255 with
-beginSheetForDirectory and -openPanelDidEnd.

Huh? Using a sheet on what window? Normally, an open panel that opens a new document is a free-standing open dialog. Or have you already arranged to open a new document window and *then* issue the open sheet on it? Either way, it *sounds* like you're abusing the user interface.


Works like a charm. But is this the "right" way to go, or is there a more
cocoa-ish way to do it using?


One thing that leads me to this question is that I can't seem to find
simple a way to hook up File->Open Recent. Documentation says of
-noteNewRecentDocumentURL:(NSURL *)aURL that "NSDocument automatically
calls this method when appropriate for NSDocument-based applications."

You say that the application is document-based, but you're bypassing NSDocument in several key places, so I'm not surprised you're seeing odd things happen. But if "hook up" means you're trying to add things to the menu, you just call this method after you've opened a file. If "hook up" means detect when a file is chosen from the menu, I guess you'd use application:openFile: like the documentation says. Except that the NSDocument you're bypassing is probably already handling this and throwing it away because you haven't given it a way of *really* opening a document.


Is there a NSDocument method I should be overriding?  It's probably
obvious, but there is sooo much to read...

I think the method you want to override is readFromURL:ofType:error:, and you should forget about findDatabase. readFromURL:ofType:error: will tell you the name of the database you should use, and will properly integrate into the NSDocument metaphor.


In that override, you would connect to the database, and you'd be done.

You'd also want to decide what to do about saving (or not saving, if that's the metaphor you want), but that's a different subject.

Sorry, I may be misunderstanding all the considerations here, but it sounds like you'd have better success by using NSDocument normally, and overriding the proper 'read' method.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Opening persistent data store (From: John Velman <email@hidden>)

  • Prev by Date: IKFilterUIView uiConfiguration values - huh?
  • Next by Date: Re: Core Data entity fetching by date
  • Previous by thread: Re: Opening persistent data store
  • Next by thread: TypographyPanel.bundle and GC-only app
  • Index(es):
    • Date
    • Thread