forked from jerrykrinock/CategoriesObjC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSDocumentController+DisambiguateForUTI.h
75 lines (62 loc) · 2.73 KB
/
NSDocumentController+DisambiguateForUTI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#import <Cocoa/Cocoa.h>
/*!
@brief This category augments NSDocumentController
methods for getting and converting among (1) the old
"document type", which was the string in the Info.plist, (2)
new "document type", which is the UTI, and (3) the "file type",
which is the filename extension.
@details This category requires that the host application has
defined a UTI for each of its document types.
Those "three document type attributes" are:
Display Name, UTI, and Filename Extension.
We define "Display Name" as the "Kind" of the document shown
when inspecting a document in the Finder It is shown
in Xcode's Target Inspector > Properties as "Name". It is also shown in the application's
Info.plist as CFBundleTypeName. A given document type has
only one Display Name. Note that invoking the Apple method
[[NSDocumentController sharedDocumentController] displayNameForType:[[NSDocumentController sharedDocumentController] defaultType]]
returns the "Display Name" as we have defined it if a document's
UTI has not been defined, but returns nil if UTI has been
defined. I'm not sure if this is a bug or if their
purposes are just way over my head.
We define "UTI" as the "UTI" shown in Xcode's Target Inspector >
. "UTI" does not seem to be visible in Finder.
UTI is also shown in the application's Info.plist as an element
of the array LSItemContentTypes.
Apparently, a given document type may have more than one Filename
Extension.
We define "Filename Extension" as the "Extension" of the document shown
when inspecting a document in the Finder It is shown in Xcode's
Target Inspector > Properties as "Extension". It is also shown
in the application's Info.plist as an element of the array
CFBundleTypeExtensions. Apparently, a given document type may
have more than one Filename Extension. The "Filename Extension"
is also called the "file type" in Apple documentation.
*/
@interface NSDocumentController (DisambiguateForUTI)
/*!
@brief Returns the first filename extension for the application's
document type with a given UTI.
*/
- (NSString*)filenameExtensionForDocumentUTI:(NSString*)uti ;
/*!
@brief Returns the "Display Name" of the application's document type
with a given UTI.
*/
- (NSString*)displayNameForDocumentUTI:(NSString*)uti ;
/*!
@brief Returns the first UTI for the application's default
document type.
*/
- (NSString*)defaultDocumentUTI ;
/*!
@brief Returns the Display Name for the application's default
document type.
*/
- (NSString*)defaultDocumentDisplayName ;
/*!
@brief Returns the first filename extension for the application's
default document type.
*/
- (NSString*)defaultDocumentFilenameExtension ;
@end