Reading plist file into an NSDictionary


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. NSString *thePath = [[NSBundle mainBundle] pathForResource:@"matchgame" ofType:@"plist"];
  2. matchData = [[NSDictionary alloc] initWithContentsOfFile:thePath];
  3.  
  4. if (mylevel == 0) {
  5. NSDictionary *mybasics = [[[NSDictionary alloc] initWithDictionary:[matchData objectForKey:@"easy"]] autorelease];
  6. numberOfImages = [[mybasics valueForKey:@"numberOfImages"] integerValue];
  7. matchOpacity = [[mybasics valueForKey:@"matchOpacity"] floatValue];
  8. cardimage = [mybasics valueForKey:@"imageName"];
  9. matchlevel = [[mybasics valueForKey:@"numberOfCards"] integerValue]; //kEasyMatch;
  10. numrows = [[mybasics valueForKey:@"numRows"] integerValue];//2;
  11. numcolumns = [[mybasics valueForKey:@"numColumns"] integerValue];//5;
  12. cardwidth = [[mybasics valueForKey:@"cardWidth"] floatValue];//78.0;
  13. cardheight = [[mybasics valueForKey:@"cardHeight"] floatValue];//78.0;
  14. xgridoffset = [[mybasics valueForKey:@"xGridOffset"] floatValue];//15;
  15. ygridoffset = [[mybasics valueForKey:@"yGridOffset"] floatValue];//100;
  16. xoffset = [[mybasics valueForKey:@"xOffset"] floatValue];//15;
  17. yoffset = [[mybasics valueForKey:@"yOffset"] floatValue];//15;
  18. isRotated = [[mybasics valueForKey:@"isRotated"] boolValue];
  19. useCollectedCards = [[mybasics valueForKey:@"useCollectedCards"] boolValue];
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.