To store the data in XML, we will first add the value we want to store in the players
array we created. Then, we will take this modified array list and call the saveXMLGroup
function, which will write the value into the XML document.
First, let's create the addXMLPlayer
function, which will add a new player to the array, as follows:
-(void) addXMLPlayer:(Player)player { NSValue *value = [NSValuevalueWithBytes:&player objCType:@encode(Player)]; [playersaddObject:value]; }
There is nothing fancy here; we are just taking the player and storing it in NSValue
and then adding the value to the players
array, as follows:
- (void) saveXMLGroup{ GDataXMLElement * groupElement= [GDataXMLNodeelementWithName:@"Group"]; NSLog(@"Player count: %lu", (unsigned long)players.count); for(inti = 0; i<players.count ; i++) { Player player; NSValue *value = [players objectAtIndex:i]; [valuegetValue:&player]; GDataXMLElement * playerElement...