Re: UTI strings
Re: UTI strings
- Subject: Re: UTI strings
- From: Ken Thomases <email@hidden>
- Date: Mon, 31 May 2010 03:53:58 -0500
On May 30, 2010, at 5:15 PM, julius wrote:
> On 30 May 2010, at 20:21, Ken Thomases wrote:
>
>> On May 30, 2010, at 1:04 PM, julius wrote:
>>
>>> unless of course there's a way of specifying the constants for NSAttributedString using the kUTTypes that I've not found yet
>>
>> The Snow Leopard AppKit release notes <http://developer.apple.com/mac/library/releasenotes/cocoa/appkit.html> include this:
>>
>>> NSAttributedString Constants
>>>
>>> The existing NSDocumentTypeDocumentAttribute and NSDocumentTypeDocumentOption express document types in terms of a set of constants particular to NSAttributedString. In Snow Leopard, there are new constants, NSFileTypeDocumentAttribute and NSFileTypeDocumentOption, that express the same information in terms of system-wide UTIs. Where these are used for output, in expressing the type of a document that has been read, both file type and document type will be provided; as input, however, when indicating the type to be written or the type to be forced on loading, the two are mutually exclusive.
>>
> I'm sorry but I've read and re-read this paragraph, in the original, a number of times including the relevant NSFileAttributeOption and NSFileTypeDocumentAttribute entries in NSAttributedString application kit additions reference and can't make head or tail of what is being talked about. Maybe it's something to do with the grammar. For me it does not parse.
I'm not sure where your confusion is originating.
It means that when NSAttributedString gives you file/document type information, it will give you both NSDocumentTypeDocumentAttribute (with a NS*DocumentType value) and NSFileTypeDocumentAttribute (with a UTI value). That is, it gives you the type information in both forms.
When you are telling NSAttributedString what type a file or document is or should be, you may pass EITHER NSDocumentTypeDocumentOption (with a NS*DocumentType value) OR NSFileTypeDocumentOption (with a UTI value), but not both. That is, you must tell it the type information in only one form, to avoid the possibility of conflicts or ambiguity.
That said, if you can target 10.6 or later, you can completely replace your uses of NSDocumentTypeDocumentAttribute/Option and NS*DocumentType with NSFileTypeDocumentAttribute/Option and UTIs.
If you really want to map from NS*DocumentType values to UTIs, you can create a data or filewrapper object from an NSAttributedString using an NS*DocumentType and then reverse the operation (create an attributed string from the data or filewrapper object) and get a document attributes dictionary, which will include a NSFileTypeDocumentAttribute key giving the relevant UTI. However, the mapping you get in this manner is not set in stone.
Regards,
Ken
_______________________________________________
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