My application handles with files of type *.mndl
which is not more than a customized *.plist
.
Up until now I've been using *.plist
files but now I want to associate the extension and be able to open *.mndl
files from any other app I have realized that renaming file.plist
to file.mndl
does not work. (Hence, I don't even know if I did correctly the extension association and exportation thing)
I sent to myself a file file.mndl
from the computer and when received in mail.app I got
file.mndl.plist
(It was automatically renamed, this happened when reseting my iPad)
How can I create my own mndl files while being able to read its content using +dictionaryWithContentsOfFile:
from NSDictionary class?
Even I am working with iOS I believe this kind of things were ported from MacOS and Cocoa. So Cocoa developers also could know this.
Your comments/answers are appreciated.
Thanks
ANSWERED: Just for completion purposes This is the addition I made to my info.plist:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Mandala Chart File</string>
<key>UTTypeIdentifier</key>
<string>com.nacho4d.Accordion.mndl</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>mndl</string>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Document320Icon.png</string>
<string>Document64Icon.png</string>
</array>
<key>CFBundleTypeName</key>
<string>Mandala Chart File</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.nacho4d.Accordion.mndl</string>
</array>
</dict>
</array>
At least for a Cocoa (desktop) app, you'd want to add the following information to your application's Info.plist.
http://www.markdouma.com/developer/nacho.plist
Obviously, you should change the uniform type identifier to something appropriate. (I usually do com.markdouma.something, since that's my website).
Note that you only want to specify an entry for NSDocumentClass if you plan on using Cocoa's NSDocument architecture by creating an NSDocument subclass to handle loading the files. Otherwise, you could always just implement the following < NSApplicationDelegate > (read that as application delegate protocol) method:
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames;
That will give you an NSArray of NSStrings representing the POSIX paths to the files the user double-clicked on in the Finder (or dragged to the app icon, etc.)
If you want to go the NSDocument route, you can override the following method of NSDocument
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)outError;
and create your dictionary with [[NSDictionary dictionaryWithContentsOfFile:[url path]] retain];
Hope this helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With