Advertisement
Guest User

Untitled

a guest
May 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  2.    
  3.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  4.        
  5.         NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  6.         NSString *file = [[path objectAtIndex:0] stringByAppendingPathComponent:@"hosts.plist"];
  7.        
  8.         NSMutableArray *newhosts = [[NSMutableArray alloc] initWithArray:hosts];
  9.                                    
  10.         [newhosts removeObjectAtIndex: indexPath.row];
  11.        
  12.         [newhosts writeToFile:file atomically:YES];
  13.        
  14.         hosts = newhosts;
  15.        
  16.         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  17.        
  18.         // [[NSNotificationCenter defaultCenter] postNotificationName:@"hostsSaved" object:nil];
  19.        
  20.         [table reloadData];
  21.  
  22.         [newhosts release];
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement