Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. {"UserData": {
  2. "Name": Mike Smith,
  3. "Age": 32,
  4. "category": [1,2,3],
  5. "Weekly Data": [
  6. {"Monday" : [1.0,2.0,3.0]},
  7. {"Tuesday": [1.0,2.0,3.0]}
  8. ]
  9. }
  10. }
  11.  
  12. -(NSString*)populateUserPreferences
  13. {
  14. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  15. NSMutableArray *categorydata = [[NSMutableArray alloc] init];
  16. NSMutableArray *weeklydata = [[NSMutableArray alloc] init];
  17.  
  18. for (int i=0;i<4; i++)
  19. {
  20. [categorydata addObject:[NSNumber numberWithInt:i]];
  21. }
  22.  
  23.  
  24. NSMutableArray *mondaydata = [[NSMutableArray alloc] init];
  25. for (int j=0; j<3; j++)
  26. {
  27. [mondaydata addObject:[NSNumber numberWithInt:j]];
  28. }
  29.  
  30. NSMutableArray *tuesdaydata = [[NSMutableArray alloc] init];
  31. for (int j=0; j<3; j++)
  32. {
  33. [tuesdaydata addObject:[NSNumber numberWithInt:j]];
  34. }
  35.  
  36.  
  37. NSDictionary *monday = [NSDictionary dictionaryWithObject:mondaydata];
  38. NSDictionary *tuesday = [NSDictionary dictionaryWithObject:tuesdaydata];
  39.  
  40. [weeklydata addObject: monday ];
  41. [weeklydata addObject: tuesday ];
  42.  
  43. }
  44.  
  45. [dict setObject:[NSString stringWithFormat:"Mike Smith"] forKey:@"Name"];
  46. [dict setObject:[NSNumber numberWithInteger:32.0] forKey:@"Age"];
  47.  
  48. [dict setObject:categorydata forKey:@"category"];
  49. [dict setObject:weeklydata forKey:@"Weekly Data"];
  50.  
  51. NSString * userdata = [dict JSONRepresentation];
  52. NSLog(request);
  53.  
  54. NSDictionary *userdataJson = [NSDictionary dictionaryWithObject:dict forKey:@"userData"];
  55.  
  56. return [userdataJson JSONRepresentation];
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement