title: Migrating, and add data, on file using NSDictionary code issues
body: <p>I am migrating from an old version (v2) to the new version (v3) of my app and by that adding two new fields for each player into the playerdata.plist. The reason why i am putting '99' in the new fields is only for testing as i am testing on a v3 file, with the extra fields, to make it easier. </p>
  
  <p>What i am trying to accomplish is:</p>
  
  <p>a. read the file with the player data </p>
  
  <p>b. add to new fields</p>
  
  <p>c. store the file</p>
  
  <p>The current result is that i am storing the same data for each players after the migration.</p>
  
  <p>Code:</p>
  
  <pre><code>- (void)migratePlayerDataPlist {
  //====THIS PIECE OF CODE SHOULD BE REMOVED AFTER CERTAIN TIME AS IT WILL NOT BE NEEDED====//
  //====..WHEN ALL OLD USERS HAVE MIGRATED. THIS IS WRITTEN SEPTEMBER 5 2012 VERSION 3.0====//
  
  // This procedure migrates the old playerdatafile to version 3 of the game
  
  //Prepare File Manager
  NSString *filePath = [self dataFilePath]; 
  
  NSFileManager *fileMgr;
  fileMgr = [NSFileManager defaultManager];
  
  if ([fileMgr fileExistsAtPath: filePath] == YES) {
  
  
      dataArray = [[NSMutableArray alloc]init];
  
      NSMutableDictionary *gameFileDict = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
  
      NSLog(@"gameFileDict: %@", gameFileDict);
  
      myKeyArray = [gameFileDict allKeys];
  
      int nrOfKeys = [myKeyArray count];
  
      NSMutableDictionary *migrationDict = [[NSMutableDictionary alloc]initWithCapacity:200];
      NSMutableDictionary *xmigrationDict = [[NSMutableDictionary alloc]initWithCapacity:200];
      NSLog(@"nrOfKeys: %i", nrOfKeys);
  
      for (int oo = 0; oo &lt; nrOfKeys; oo++) {
  
          [dataArray removeAllObjects]; // Clean array
  
          theObjects = [gameFileDict valueForKey:[myKeyArray objectAtIndex:oo]];
          [dataArray addObject:[theObjects objectAtIndex:0]]; // diffSelection
          [dataArray addObject:[theObjects objectAtIndex:1]]; // # of games played
          [dataArray addObject:[theObjects objectAtIndex:2]]; // # correct answers
          [dataArray addObject:[theObjects objectAtIndex:3]]; // # questions
          [dataArray addObject:[NSNumber numberWithInt:99]];   // &gt;&gt;New field&lt;&lt; # of games won
          [dataArray addObject:[NSNumber numberWithInt:99]];   // &gt;&gt;New field&lt;&lt; # of games lost
  
          xmigrationDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:dataArray, [myKeyArray objectAtIndex:oo], nil];
  
          [migrationDict addEntriesFromDictionary:xmigrationDict];
      }
  
      NSLog(@"xmigrationDict: %@", xmigrationDict);
      NSLog(@"migrationDict: %@", migrationDict);
      NSLog(@"theObjects: %@", theObjects);
  
      // Delete the old file
      [fileMgr removeItemAtPath:filePath error:NULL];
  
      // Resave the file with the new data
      [migrationDict writeToFile:filePath atomically: TRUE];
  
      //  ...and the migration is done
  
  }   
  }
  </code></pre>
  
  <p>Current NSLog-based output:</p>
  
  <pre><code>2012-09-06 20:57:50.332 xxxx_3[1505:fb03] gameFileDict: {
  Barnspelare =     (
      1,
      1,
      2,
      2,
      1,
      0
  );
  "Ton\U00e5rsspelare" =     (
      2,
      0,
      0,
      0,
      0,
      0
  );
  Vuxenspelare =     (
      3,
      1,
      0,
      2,
      0,
      1
  );
  }
  2012-09-06 20:57:50.334 xxxx_3[1505:fb03] nrOfKeys: 3
  2012-09-06 20:57:50.335 xxxx_3[1505:fb03] xmigrationDict: {
  "Ton\U00e5rsspelare" =     (
      2,
      0,
      0,
      0,
      99,
      99
  );
  }
  2012-09-06 20:57:50.336 xxxx_3[1505:fb03] migrationDict: {
  Barnspelare =     (
      2,
      0,
      0,
      0,
      99,
      99
  );
  "Ton\U00e5rsspelare" =     (
      2,
      0,
      0,
      0,
      99,
      99
  );
  Vuxenspelare =     (
      2,
      0,
      0,
      0,
      99,
      99
  );
  }
  2012-09-06 20:57:50.336 xxxx_3[1505:fb03] theObjects: (
  2,
  0,
  0,
  0,
  0,
  0
  )
  </code></pre>