• 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
NSFileWrapper, type & creator -> questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFileWrapper, type & creator -> questions


  • Subject: NSFileWrapper, type & creator -> questions
  • From: Nick Müller <email@hidden>
  • Date: Thu, 10 Jan 2002 16:07:32 +0100

Hi,

Reading the documentation for NSFileWrapper, it seems that it is
suitable for assigning creator codes to new files. But I can't.

Here is what I did:

Given:
creator: 'FooB'
application-name: "GreatApp"
icon: "GreatApp.icns"
file-extension: ".ext" // just kidding

Creating a new file
----
NSFileWrapper *file = [[NSFileWrapper alloc]
initWithRegularFileContents:nil];
NSMutableDirectory *attributes = [[NSMutableDirectory alloc] init];
[attributes setObject: [NSNumber numberWithUnsignedInt: 'FooB']
forKey:@"NSHFSCreatorCode"];
[attributes setObject: @"NSFileTypeRegular" forKey:@"NSFileType"];
[attributes setObject: [NSNumber numberWithUnsignedInt:0777]
forKey:@"NSFilePosixPermission"];
[file setFileAttributes: attributes];
[file writeToFile:@"file.ext" atomicaly:NO updateFilenames:YES];
----

This works partial as the file is created, but looking at the files
info, there is no creator and no icon.

OK, maybe I must do something more in the target settings of the
programm generating that file...

Target -> Application Settings (Expert mode)
CFBundleDocumentTypes
[one entry]
CFBundleTypeExtensions
[one entry]
"ext"
CFBundleTypeIconFile: "GreatApp.icns"
CFBundleTypeName: "GreatApp"
CFBundleTypeRole: "Editor"


Still not working. I can't find any examples, especially dealing with
NSFileWrapper:setFileAttributes that are using the creator code.

Yes, the file is on a HFS-volume.

What am I missing?


Another question is about extensions (duck):
As I can't be sure that no one other gets the idea to use ".ext" for his
files, how about using the assigned creator ("FooB") and hide the
extension?


TIA,
Nick
.........................................
logic tools

WebObjects // Web Authoring // Perl
Nick Mueller // Muenchen // Germany


  • Follow-Ups:
    • Re: NSFileWrapper, type & creator -> questions
      • From: Nick Müller <email@hidden>
  • Prev by Date: Problem with NSSplitView
  • Next by Date: Launching Multiple Instance of an Application
  • Previous by thread: Re: Problem with NSSplitView
  • Next by thread: Re: NSFileWrapper, type & creator -> questions
  • Index(es):
    • Date
    • Thread