• 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
Creating/Saving a document package
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating/Saving a document package


  • Subject: Creating/Saving a document package
  • From: Daniel Stark <email@hidden>
  • Date: Wed, 21 Aug 2002 19:47:19 -0500

I am making a little 2d racing game in objective c and want to save courses as document packages. I have looked through the archives and found a few helpful posts but I'm still having trouble. I have added an file type with extension ".track" to my app. I have placed the built app into the Applications folder logged out and in and the finder/launch services seems to have caught on (I can create a folder and add the ".track extension and it turns into a package).

Now my problem, I gather I use the FileWrapper class to create these files programmatically but I can't seem to get it to work, here is my code. I get this error when the following method is run:

*** -[NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil value

Seems the although data has data but the coursewrapper FileWrapper is null. How can I load my data into the wrapper and once I do will the result of the rest of the method be a file on my desktop (Malibu.track) that contains "course"


- (IBAction)saveIt:(id)sender
{
BOOL result;
NSDictionary *dict;
NSFileWrapper *wrapper;
NSData *data;
NSFileWrapper *coursewrapper = [[NSFileWrapper alloc] initWithSerializedRepresentation:[NSArchiver archivedDataWithRootObject:course]];
data = [NSArchiver archivedDataWithRootObject:course];
[coursewrapper setPreferredFilename:@"course"];
dict = [NSDictionary dictionaryWithObject:coursewrapper forKey:@"course"];
wrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:dict];
[wrapper writeToFile:@"/Users/dstark/Desktop/Malibu.track" atomically:YES updateFilenames:YES];
}
_______________________________________________
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: Newbie *me = [[Newbie alloc] initWithProblem:customViewDrawing];
  • Next by Date: Re: NSTimer in a secondary thread?
  • Previous by thread: Re: Newbie *me = [[Newbie alloc] initWithProblem:customViewDrawing];
  • Next by thread: Make Monaco font bold?
  • Index(es):
    • Date
    • Thread