• 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
fileWrapperRepresentationOfType and PkgInfo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fileWrapperRepresentationOfType and PkgInfo


  • Subject: fileWrapperRepresentationOfType and PkgInfo
  • From: Tod Cunningham <email@hidden>
  • Date: Mon, 16 Feb 2004 11:16:30 -0500

I have a document that writes out a package file type (RTFD). I want to add the type/creator code to the package which can be done by adding a PkgInfo file to a directory called "Contents" within the package. The trick is now how do I add this file to the package? I am trying to add it from the fileWrapperRepresentationOfType method by modifying the NSFileWrapper that is returned from RTFDFileWrapperFromRange:

- (NSFileWrapper *)fileWrapperRepresentationOfType:(NSString *)docType
{
NSMutableDictionary *fileAttr = [[NSMutableDictionary alloc] init];
NSRange range = NSMakeRange( 0, [[labelText string] length] );
NSFileWrapper *fileWrapper;

if( [docType isEqualToString:@"Label with Images"] )
{
fileWrapper = [[labelText textStorage] RTFDFileWrapperFromRange:range documentAttributes:fileAttr];
}
else
{
fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:[labelText RTFFromRange:range]];
[fileAttr addEntriesFromDictionary:[fileWrapper fileAttributes]];
[fileWrapper setFileAttributes:fileAttr];

[fileWrapper autorelease];
}

[fileAttr release];
return( fileWrapper );
}


However, the NSFileWrapper methods don't seem to work as I would expect. When I try to send a message such as addFileWithPath it always returns NIL. Does anyone have any pointers on how to do this?

Thanks,

Tod Cunningham
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Slow Cocoa
  • Next by Date: Re: Better way to deal with NSFontPanel in a preference pane
  • Previous by thread: Re: Problems with NSFont and (NSFont *)fontWithName:(NSString *)fontName size:(float)fontSize
  • Next by thread: Sorting NSTableView with NSDictionary objects in Panther
  • Index(es):
    • Date
    • Thread