我正在尝试删除数组中的行,从点击删除按钮,点击编辑后,然后点击红色减号小按钮。当我在模拟器上点击删除按钮时,什么也没有发生。如果有人可以帮助我,请。这是我的代码:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
//here is where the magic doesn't happens
if (editingStyle == UITableViewCellEditingStyleDelete) {
[stories removeObjectAtIndex: storyIndex];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @"module"];
// clean up the link - get rid of spaces, returns, and tabs...
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"link: %@", storyLink);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
}