Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)rightSwipe:(UIGestureRecognizer *)gestureRecogniser {
- // A right swipe sets the status to completed
- NSInteger row = [self rowForRecogniser:gestureRecogniser];
- if (row == NSNotFound)
- {
- return;
- }
- NSMutableArray *taskArray = [[self.controller fetchedObjects]mutableCopy];
- Task *task = [taskArray objectAtIndex:row];
- for (int i = 0; i < [taskArray count]; i++)
- {
- Task *task1 = [taskArray objectAtIndex:i];
- if(task1.completedStatus == FALSE)
- {
- m_position = i;
- m_finalIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
- }
- }
- task.completedStatus = YES;
- id obj = [noteCategoryArray objectAtIndex:row];
- [taskArray removeObjectAtIndex:row];
- [taskArray insertObject:obj atIndex:m_position];
- [m_tableView beginUpdates];
- NSIndexPath *currentIndexPath = [NSIndexPath indexPathForRow:row inSection:0];
- [m_tableView moveRowAtIndexPath:currentIndexPath toIndexPath:m_finalIndexPath];
- [m_tableView endUpdates];
- float i = 0.0f;
- for (NSManagedObject *mo in taskArray)
- {
- [mo setValue:[NSNumber numberWithFloat:i++] forKey:@"displayOrder"];
- NSError *error = nil;
- if (![self.managedObjectContext save:&error])
- {
- NSString *msg = @"An error occurred when attempting to save your user profile changes.\nThe application needs to quit.";
- NSString *details = [NSString stringWithFormat:@"%@ %s: %@", [self class], _cmd, [error userInfo]];
- NSLog(@"%@\n\nDetails: %@", msg, details);
- }
- // re-do the fetch so that the underlying cache of objects will be sorted
- // correctly
- if (![self.controller performFetch:&error])
- {
- NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
- abort();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement