Im able to receive tasks but in each run the order of tasklists vary. I need to have the same order of task lists in each run.
How i fetch now is,
GTLServiceTasks *service = self.taskService;
query = [GTLQueryTasks queryForTasklistsList];
self.taskListsTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
id taskLists, NSError *error) {
//i get the count of Tasklists here
GTLTasksTaskList *itemtemp;
for (int k=0; k<count_of_tasklists; k++) {
NSMutableArray *alist = [[NSMutableArray alloc] init];
//i get the id and titles of the tasklists here
GTLServiceTasks *service2 = self.taskService;
query2 = [GTLQueryTasks queryForTasksListWithTasklist:itemtemp.identifier];
self.taskListsTicket = [service2 executeQuery:query2
completionHandler:^(GTLServiceTicket *ticket2,
id taskLists2, NSError *error2) {
self.taskLists = taskLists2;
for (int j=0; j<[self.taskLists.items count]; j++) {
//i get tasks for each tasklist here and store each one of
//the tasklists as a nsmutablearray
}
[tasks addObject:alist];
//i add each tasklist array to the master array
// then call reload method of the uitableview here
}];
}
}];
In the uitableview that i present the tasks i use section titles for tasklist titles and rows for task titles. In each run the correct tasks are presented under the correct sections.
My problem is that the order of tasklists (order of sections) are different in each run, both in my uitableview and console log of GTL replies. I think the for loop works without waiting the result from the Google Api call. Any ideas about the issue?
Thanx in advance