How do I load a directory into a document-based app?
How do I load a directory into a document-based app?
- Subject: How do I load a directory into a document-based app?
- From: "Alan Smith" <email@hidden>
- Date: Wed, 18 Oct 2006 12:28:44 -0400
I'm trying to write a text editor and it all works except the saving.
I want to load a directory the way TextMate does. It puts all of the
files of the directory in an outline view and you can edit the files
indivisually. I've achieved that.
I have put an entry in Info.plist as follows:
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string></string>
</array>
<key>CFBundleTypeName</key>
<string>Folder</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSTypeIsPackage</key>
<false/>
<key>NSDocumentClass</key>
<string>FileEditor</string>
</dict>
I can use that to drop a folder onto the app's icon in the dock and it
loads. No problem. I do have problems however when I try to save the
files. Currently I have it save the selected file in the outline view.
No matter how I try to save, somehow the original folder disappears
from my hard disk! Here is my saving code:
- (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
error:(NSError **)outError
{
if (saveAll == NO)
{
if ([outline selectedRow] != -1)
{
AOTree *item = [outline itemAtRow: [outline selectedRow]];
NSString *name = [item displayName];// stringByDeletingPathExtension];
//name = [name stringByAppendingString: typeName];
if ([[files objectForKey: [item path]] writeToFile: [item path]
atomically: YES encoding: NSUTF8StringEncoding error: outError])
{
unsavedFileCount--;
}
}
}
if (unsavedFileCount <= 0)
{
[self updateChangeCount: NSChangeCleared];
}
else
{
[self updateChangeCount: NSChangeDone];
}
return YES;
}
It is not very functional, and not complete, but should save the file.
It doesn't.
So, how do I change the Info.plist file so that I can load directories
but prevent them from appearing as a format in the save dialogs? My
hope is that the only problem is the Info.plist file and that a proper
fix will cause my troubles to cease.
Many thanks, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unimportant, then it
shall evolve."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden