• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Multiple Documents?! [newbie] [again]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple Documents?! [newbie] [again]


  • Subject: Re: Multiple Documents?! [newbie] [again]
  • From: Michael Heinz <email@hidden>
  • Date: Wed, 3 Nov 2004 21:11:29 -0500

Dominik -

I've been through this myself. It's easy, but the documentation and tutorials seem to hide it. You need to override the readFromFile: method in your Document class. In addition, you're going to want to look into NSFileWrapper and how that works.

Here's a code fragment from something I'm playing around with - it unpacks a compressed file so you can play with the files inside:

- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType
{
char buffer[MAXPATHLEN*2];
char pkgName[MAXPATHLEN];


packageName = [fileName retain];
tmpnam(temporaryName);
mkdir(temporaryName);


[fileName getCString:pkgName maxLength:MAXPATHLEN];

if ([fileName hasSuffix: @".cbr"]) {
/* MHEINZ - change unrar directory to a property. */
sprintf(buffer,"cd '%s'; /sw/bin/unrar e -o+ -y -p- '%s'",temporaryName,pkgName);
} else {
/* MHEINZ - change unzip directory to be a property. */
sprintf(buffer,"/sw/bin/unzip -d '%s' -o -j '%s'",temporaryName,pkgName);
}
system(buffer);

{
NSFileWrapper *wrapper = [[NSFileWrapper alloc] initWithPath: [NSString stringWithCString: temporaryName]];
pages = [[wrapper fileWrappers] retain];
pageNames = [[[pages allKeys] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
pageCount = [pageNames count];
#if 0
NSLog([NSString stringWithFormat: @"Directory has %d entries.",[pages count]]);
for (currentPage=0;currentPage<pageCount;currentPage++) {
NSLog([pageNames objectAtIndex: currentPage]);
}
#endif
}
currentPage=0;


[self displayPage];


return YES;
}

On Nov 3, 2004, at 3:08 PM, Dominik Pich wrote:

I cant believe nobody can answer that question...

I created a cocoa document-based app and now need for each document to open not only single files with extensions specified in the plist but also folders AND multiple files per documents (which per default open multiple documents).

How do I do that?
Thanks
---
May you always find water and shade. - Wheel Of Time
Dominik
 _______________________________________________
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

References: 
 >Multiple Documents?! [newbie] [again] (From: Dominik Pich <email@hidden>)

  • Prev by Date: Re: nextKeyView and NSTabView: How to prevent the tabbing order from going out of the tab view?
  • Next by Date: Re: Lame problem with NSImageView
  • Previous by thread: Multiple Documents?! [newbie] [again]
  • Next by thread: File Package advice
  • Index(es):
    • Date
    • Thread