Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)refreshItems {
- NSInteger userId = [[[PKAPIClient sharedClient].oauthToken.refData pk_objectForKey:@"id"] integerValue];
- //Dictionary-ise the user details
- NSDictionary *userDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- @(userId), @"id",
- @"user", @"type",
- nil];
- // Dictionary-ise the filters, including the dictionary-ised user details
- NSDictionary *filterDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- userDict, @"created_by",
- nil];
- PKRequest *request = [PKItemAPI requestForItemsInAppWithId:cCallsAppID
- viewId:cCallsViewID
- filters:filterDict
- offset:0
- limit:0];
- // Attach an object mapping to the request
- request.objectMapping = [PSItemMapping mapping];
- request.objectDataPathComponents = @[@"items"];
- [request startWithCompletionBlock:^(NSError *error, PKRequestResult *result) {
- if (error == nil) {
- // Success
- self.items = result.resultData; //Result data contains the mapped objects
- NSLog(@"resultData: %@", result.resultData);
- // resultData: (null)
- NSLog(@"items: %@", self.items);
- // items: (null)
- NSLog(@"count of items: %lu", (unsigned long)[self.items count]);
- // count of items: 0
- NSLog(@"parsedData: %@", result.parsedData);
- //parsedData: { filtered = 2; items = {...}; total = 11526; }
- [self.tableView reloadData];
- } else {
- // Failure
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
- message:@"Failed to load data."
- delegate:nil
- cancelButtonTitle:@"OK"
- otherButtonTitles:nil];
- [alert show];
- }
- }];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement