lundi 23 février 2015

NSOperationQueue blocks UITableView

The following code is by another employee at my company, but i have to solve the performance-issue now...


The method 'deleteObjectAndAllDependencies' deletes the project and the related data from our SQLite DB...


The tableView isn't usable still everything is performed. How can i speed up this process? Without using functionality.


-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {



if (editingStyle == UITableViewCellEditingStyleDelete) {

if ([[SARAM RAM] selectedProjektIndex] == indexPath.row) [[SARAM RAM] setSelectedProjektIndex:0];

NSBlockOperation *start = [NSBlockOperation blockOperationWithBlock:^{

[[SAAufmassProject popFromDatabaseForGUID:[SARAM projektPool][indexPath.row]] deleteObjectAndAllDependencies];

[[self projectData] removeObjectAtIndex:indexPath.row];
}];

NSBlockOperation *refresh = [NSBlockOperation blockOperationWithBlock:^{

[tableView beginUpdates];

[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

[tableView endUpdates];

[self dataHasBeenDeleted];
}];

[refresh addDependency:start];

[[NSOperationQueue currentQueue] addOperation:start];
[[NSOperationQueue currentQueue] addOperation:refresh];
}

}

Aucun commentaire:

Enregistrer un commentaire