Re: Importing to core data persistent document
Re: Importing to core data persistent document
- Subject: Re: Importing to core data persistent document
- From: Gideon King <email@hidden>
- Date: Thu, 5 Aug 2010 14:09:11 +1000
Answers:
1. It could come from a File/Open, or them opening that file from the Finder, or from a File/Import command (the import one just calls the document controller's openDocumentWithContentsOfURL:display:error anyway, so they all go through the same mechanism)
2. The file needing conversion does not require core data for the conversion. My file format is in core data.
3. Yes, the intention is so that it is treated as a new document. This works for the NSDocument side of things - I use the Save command, and it asks for a file name. It does not work for the persistent store side of things, because it tries to save back to the original file as well as writing a blank file to the new location. When you create a new document and save it for the first time in Core Data, it treats it exactly the same way as for a Save As (as far as I can tell), and that's the behavior I need in this situation, but I don't know how to achieve it because even if I tell Core Data there is no URL associated with the file (as would be the case for a new document, I assume), it still knows that it is not a new document.
On 05/08/2010, at 1:18 PM, Quincey Morris wrote:
> On Aug 4, 2010, at 19:48, Gideon King wrote:
>
>> 1. User initiates import of file of type "fred"
>> 2. I pick that up in -readFromURL:ofType:error:, and spawn a process which converts files of type "fred" to type "myfiletype", the native file type of the application. Let's say that it is stored in a file called /MyImports/file.mytype.
>> 3. Still in -readFromURL:ofType:error:, I call super, telling it to load the converted file, and then call [self setFileURL:nil]; [self setFileType:@"myfiletype"];
>
> I don't have any answers, but I was going to contribute some questions, then I realized that I don't quite understand the above. Apologies if you explained this in your original post.
>
> What's the mechanism that gets to step 1 in the above -- File | New? File | Open? File | Import? (Meaning, by the first two, the standard actions that get dispatched to NSDocumentController.)
>
> I assumed, from your statement that readFromURL:ofType:error: is invoked, that this was coming from a File | Open of the file to be converted. Is the file needing conversion a Core Data store? Or a non-Core Data file of some kind? (If the latter, I'm not sure why you think its safe to use NSPersistentDocument.)
>
> One other preliminary question:
>
> Am I correct in assuming that the intention of setting fileURL to nil is to (in effect) make the imported document untitled, so that the user will be asked for a location to save it, at the next save?
>
>
_______________________________________________
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