Re: minimum one entity instance on initial launch
Re: minimum one entity instance on initial launch
- Subject: Re: minimum one entity instance on initial launch
- From: "Jim Thomason" <email@hidden>
- Date: Wed, 8 Aug 2007 14:36:58 -0500
> I want there to be at least one entity instance on initial launch of
> the application, including any launch following the user deleting the
> persistent storage file. What's the best way to ensure this?
Couple of thoughts -
1) Are you ensuring in the interface that the user must have at least
one object? If not, you should. Bind your delete button's "enabled" on
your array controller to some parameter that returns true if there's
more than 1 item, and false if there's only 1. That way they can never
get down below 1.
2) The CoreData project template has some code in it that creates the
persistent store file if it doesn't exist. That looks like a good
place to wire into, and you're assured it's only called when the file
is created.
3) If it's document based, you can do something to create the object
if the user is opening a new file. Is there a clean method for this? I
don't recall offhand. At a minimum, you could check for [self fileURL]
== nil in windowControllerDidLoadNib, I think, and add an object
there. Is there some easier delegate based "New Document Created"
method or note or something? I guess you could subclass
NSDocumentController.
And from there I wouldn't worry about it. That creates a default and
ensures that the user can't delete it. Technically, they could
manually edit the persistent file and delete the sole object, but if
they do that they get what's coming to 'em.
-Jim.....
_______________________________________________
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