Re: Opening persistent data store
Re: Opening persistent data store
- Subject: Re: Opening persistent data store
- From: Jerry Krinock <email@hidden>
- Date: Sat, 8 Nov 2008 21:06:02 -0800
On 2008 Nov, 08, at 19:49, John Velman wrote:
-beginSheetForDirectory and -openPanelDidEnd
Yikes. Apple already did this for you. Playing with these methods is
not any fun.
Works like a charm.
Well, except for the trouble you discovered later...
But is this the "right" way to go, or is there a more
cocoa-ish way to do it using?
I believe there is a better way...
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."
Yes, and by the time you get this reply you may have discovered two or
three more little features that don't work, and you're going to be
spending the next two weeks re-implementing code for these and other
features that would "just work" if you had used the Cocoa document
architecture.
Is there a NSDocument method I should be overriding? It's probably
obvious, but there is sooo much to read...
Try -[NSDocument readFromData:ofType:error:]. True, because you must
read an sqlite database, you're not going to use the data that you are
passed as an argument. But that's OK. It will be autoreleased and go
away.
Unless you already did this and can remember how to un-hack all the
things you hacked, it might be better to start over by clicking in the
Xcode menu, File > New Project > Cocoa Document-Based Application and
move your code into this new project. The default MyDocument.m file
will contain a skeleton implementation of [NSDocument -
readFromData:ofType:error:]. Put your findDatabase code in there.
Unfortunately, I can't promise that taking my advice will make
everything wonderful, because whenever you can't use the Cocoa
architectures exactly as Apple had intended you're going to find
things that need patching. But I believe that the more you can "stick
with the program", the less work you'll ultimately have to do.
_______________________________________________
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