When carrying out the development of iOS macOS,We often need to interact and file,For example, association and open a certain type of file,Well, this time,Your name suffix used in this document are not,But it's UTI。
UTI is a unified file type name,It sets out what should be a file type,Rather than suffixes to determine,For example, txt,text,json are plain text files,They are public.text
Then,usually,For the well-known file types,You can go toApple's official pageView the list,Here we show the most common extensions should correspond to the UTI for you。
But these are only a small part,There are many known file suffix does not exist in this list among,such as .plist ,Then,We want to how to do it? Themselves to declare it?
Obviously,Declared himself a common suffix is the existence of hidden,Then,You can use the command line tools on macOS to determine the file type。
First of all,You need to have a .plist file,Then you can execute the following command:
1 |
mdls -name kMDItemContentTypeTree "your/path/to/file.plist" |
This type of tree can get the file,The topmost is its type。
The results you get are as follows:
1 2 3 4 5 |
kMDItemContentTypeTree = ( "com.apple.property-list", "public.data", "public.item" ) |
Then clearly, with.apple.property-list It is .plist Of the UTI。
References
Original article written by LogStudio:R0uter's Blog » UTI quick check of a file
Reproduced Please keep the source and description link:https://www.logcg.com/archives/3017.html