Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
My friends are coming this weekend and we are doing a little role gaming. I want to polish off my Xp Calc program before they come. Everything works fine with it right now. But I am adding a 'Death Certificate' button. So when you get a kill you can press the button and a window pops up. I then enter the information, for Experience Points, any Treasure, notes and a time stamp which I save as an object in an NSMutableArray. They enter information in to a few 'Wrapping Text Fields'. At the bottom of this window I will have a left and right arrow to cycle through the saved past kills, by cycling through the index's of the array.

Question:
I am already using a plist with this code. I use this to add and subtract skills from a NSPopUpButton.
Code:
-(void)loadPrefsAtStart{
   prefs = [NSUserDefaults standardUserDefaults]; // *******************    Load Prefs at start
    filemgr = [NSFileManager defaultManager];
    fileSavePath = [@"~/Documents/XPCalc.plist" stringByExpandingTildeInPath]; // Sets up the default path to the file.

    if ([filemgr fileExistsAtPath: fileSavePath ] == YES){
        skills = [[NSMutableDictionary alloc] initWithContentsOfFile: fileSavePath]; // it reads the file into the Dictionary
        for (NSString *i in skills) {         //  for loop to loop through the keys if the Dictionary and add to popUpButton
            [popUpButtonDisplay addItemWithTitle: i];
        }
    }
    else {
        skills = [[NSMutableDictionary alloc] init];
        [skills writeToFile: fileSavePath atomically:YES]; // if it can't find it, it writes a blank file.

1. Can / should I have more then 1 plist? So 1 plist for skills and another for a Death Certificate?
2. If I use 1 plist must I save everything at the same time, both skills and Death Certificate. Or can I have 2 different save buttons on each NSWindow?

I am sure a plist can hold many items, but I am guessing you have to read everything and write everything at the same time.

I tried to find information on using many plists but the info was hard to find so I am asking here how to start this project tonight on the correct path.

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.