Re: NSFileWrapper
Re: NSFileWrapper
- Subject: Re: NSFileWrapper
- From: Daryle Walker <email@hidden>
- Date: Sat, 04 Jun 2016 18:02:37 -0400
> On Jun 4, 2016, at 12:18 PM, Peter Hudson <email@hidden> wrote:
>
> Hi Mike
>
> You're right - I want the behaviour of a package. Do you happen to know how I can achieve it? I had presumed it might be some mix of flag setting at system level. If for example i set the extension on an NSFileWrapper to .bundle i get some of what I need - but I cant find out how to get an icon of my choosing associated with it.
You’ll have to work at it; it won’t be completely transparent to your users to experience nor you to program.
The “.bundle” extension is already in use for system plug-ins. You have to come up with a new extension. For instance, if you’re already using “.xyz” for you single-file format, you could use “.xyz-pkg” for your package format.
In the section of your Info.plist that describes the single-file format, add another file type for the new package format. You can have both point to the same NSDocument subclass to handle opening/saving. Of course, you have to change your reading method to detect which file object you got. You should give the users the option to save (as) in either format, and have your writing methods reflect that.
I think you mark your new file format’s package flag in the Info.plist. (I don’t know if that’s compatible with the two file formats sharing a NSDocument subclass.) As Mike said, use the NSFileWrapper APIs to create the enclosing folder (with your new extension to mark it as a package) and the files within. Also look at NSFileHandle, NSFilePresenter and NSFileCoordinator.
You don’t have to go database overkill if you don’t want to.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
> Peter
>
> Original Message
> From: Mike Abdullah
> Sent: Saturday, 4 June 2016 17:12
> To: Peter Hudson
> Cc: email@hidden List
> Subject: Re: NSFileWrapper
>
> It sounds like you want your file format to be what is known as a “package”. It’s a directory, but is (mostly) presented as a single file.
>
> NSFileWrapper is an API for working with files, it does not directly control whether something is a package or not. It just happens to be the most convenient API in Cocoa for working with packages and documents, and so NSDocument has built in support for that.
>
> Mike.
>
>> On 4 Jun 2016, at 12:01, Peter Hudson <email@hidden> wrote:
>>
>> Hi All
>>
>> Our users have now decided to push the bounds of the system - resulting in file sizes that are getting to large for comfort.
>>
>> It would be possible to fairly easily split the current file format into two and store it as two separate units. This is a particularly interesting solution as half the data rarely changes. It would however be neccessary for the two files to be handled transparently, by the user, as one unit.
>>
>> I have been looking over the docs for NSFileWrapper. I can’t see if it is possible to construct a file wrapper that presents itself to the user as ‘one file’ complete with icon - and hides the multiple files in the wrapper.
>>
>> Any suggestions / pointers gratefully recieved !
>>
>> Peter
_______________________________________________
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