Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"UserData": {
- "Name": Mike Smith,
- "Age": 32,
- "category": [1,2,3],
- "Weekly Data": [
- {"Monday" : [1.0,2.0,3.0]},
- {"Tuesday": [1.0,2.0,3.0]}
- ]
- }
- }
- -(NSString*)populateUserPreferences
- {
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
- NSMutableArray *categorydata = [[NSMutableArray alloc] init];
- NSMutableArray *weeklydata = [[NSMutableArray alloc] init];
- for (int i=0;i<4; i++)
- {
- [categorydata addObject:[NSNumber numberWithInt:i]];
- }
- NSMutableArray *mondaydata = [[NSMutableArray alloc] init];
- for (int j=0; j<3; j++)
- {
- [mondaydata addObject:[NSNumber numberWithInt:j]];
- }
- NSMutableArray *tuesdaydata = [[NSMutableArray alloc] init];
- for (int j=0; j<3; j++)
- {
- [tuesdaydata addObject:[NSNumber numberWithInt:j]];
- }
- NSDictionary *monday = [NSDictionary dictionaryWithObject:mondaydata];
- NSDictionary *tuesday = [NSDictionary dictionaryWithObject:tuesdaydata];
- [weeklydata addObject: monday ];
- [weeklydata addObject: tuesday ];
- }
- [dict setObject:[NSString stringWithFormat:"Mike Smith"] forKey:@"Name"];
- [dict setObject:[NSNumber numberWithInteger:32.0] forKey:@"Age"];
- [dict setObject:categorydata forKey:@"category"];
- [dict setObject:weeklydata forKey:@"Weekly Data"];
- NSString * userdata = [dict JSONRepresentation];
- NSLog(request);
- NSDictionary *userdataJson = [NSDictionary dictionaryWithObject:dict forKey:@"userData"];
- return [userdataJson JSONRepresentation];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement