Le 31 mai 2010 à 10:25, julius a écrit :

> 
> On 31 May 2010, at 01:42, John Joyce wrote:
> 
>> 
>> On May 30, 2010, at 5:15 PM, julius wrote:
>> 
>>> John hi
>>> On 30 May 2010, at 19:47, John Joyce wrote:
>>> 
>>>> That's not how these constants work.
>>>> These are intended to be constants that return the correct type for the 
>>>> current build of the system.
>>>> This protects your software from a change in the actual UTI of a common 
>>>> type.
>>>> 
>>> 
>>> I can understand the use of constants to such a purpose. 
>>> Hence for instance my ability to write a file as NSRTFTextDocumentType when 
>>> in the Save panel I have opted to save it as com.apple.rtfd or as a 
>>> document having no UTI at all.
>>> 
>>> If I read a document for which I have declared no UTI then the ofType 
>>> parameter in the readFromData:ofType:error: displays the Name I have used 
>>> to describe that document type. On the other hand if I have used a UTI then 
>>> it is the UTI that is passed as the ofType parameter.
>>> 
>>> So if I have this correctly, in the case of files that will only ever be 
>>> read by my application it really does not matter what extension or UTI I 
>>> give them since it is the responsibility of my code to make sense of them. 
>>> However, if I want to  write files that other applications can read I have 
>>> not only to provide the correct format but also the correct extension or 
>>> UTI . Is it therefore the case that when writing files to be read by other 
>>> applications I need not only write using the correct 
>>> NSDocumentTypeDocumentAttribute but also provide the correct UTI (or 
>>> extension)? If so then surely I need to have an idea of which UTI's (if 
>>> any) go with a given NSDocumentTypeDocumentAttribute?
>>> 
>>> Thanks
>>> Julius
>>> 
>>> 
>>> http://juliuspaintings.co.uk
>>> 
>> Your application declares the types of files it can read and/or edit. 
>> It declares these types by UTI.
> 
> That is what I thought.
>> 
>> If an application declares that it can read files of type x, then you can 
>> definitely open files of type x with that application.
>> 
>> Not all UTIs are built in the OS. 
>> They're "registered" with the OS.
>> The OS does not know about many (most?) file types out of the box.
> That too is my understanding
>> 
>> The OS can attempt to identify a file's type.
>> It doesn't always know 100% what app should or could open a file or edit it.
>> It will then give you a choice of "Recommended applications", that is, apps 
>> that are declared to read or edit a file of the UTI that the OS thinks this 
>> file might be. The OS does allow the user to choose from "All Applications" 
>> also, because the OS cannot realistically know about all file types ahead of 
>> time.
> Which is why (I think I correctly assume) one's program has to make decisions 
> regarding how to handle incoming or outgoing file data on the basis of the 
> ofType: parameter.
>> 
>> This data is covered, but you may want to explore further the docs, a few 
>> books on cocoa, and sample apps from apple.
>> Look at how they handle this.
>> Ideally, look at open source or sample apps that handle similar file types 
>> to yours.
> Yes. But I have!!! 

And have you look at the way TextEdit do that ? 

Hint: TextEdit sources are in /Developer/Examples/

-- Jean-Daniel




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to