fileWrapperRepresentationOfType and PkgInfo
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.