Is NSMutableArray can be editing or move indexPath when data is from URL?
I load data from URL to a NSMutableArray ,like this code :
NSMutableArray *mArray;
mArray = [NSMutableArray arrayWithContentsOfURL:the开发者_高级运维NewURL];
If I load this array and show on tableview
Can I move the row index and edit the table view ,ex.delete ... ???
Yes.
You can remove the item from the array and reload the tableView
NSMutableArray * mArray = [NSMutableArray arrayWithContentsOfURL:theNewURL];
[mArray removeObjectAtIndex:indexPath.row];
-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
rowNumber = indexPath.row;
UIActionSheet *registerActionSheet = [[UIActionSheet alloc] initWithTitle:@"Sure You Want To Delete?"delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Yes", nil];
registerActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[registerActionSheet showInView:self.view];
[registerActionSheet release];
// delete your data item here
// Animate the deletion from the table.
//[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
精彩评论