Sqlite数据库并滑动删除
我正在从事的项目要求我使用 sqlite 数据库,并且我一直在尝试通过滑动删除来处理我的 tableView:
[self performSelectorOnMainThread:@selector(removeMovieFromCache:) withObject:[NSNumber numberWithInt:movieId] waitUntilDone:YES];
[db performSelectorOnMainThread:@selector(performQuery:) withObject:[NSString stringWithFormat:@"DELETE FROM movie WHERE id = %d", movieId] waitUntilDone:YES];
[db performSelectorOnMainThread:@selector(performQuery:) withObject:[NSString stringWithFormat:@"DELETE FROM new_movies WHERE new_movie_id = %d", movieId] waitUntilDone:YES];
[self removeMovieFromCache:movieId];
[db performQueryWithFormat:@"DELETE FROM movie WHERE id = %d", movieId];
[db performQueryWithFormat:@"DELETE FROM new_movies WHERE new_movie_id = %d", movieId];
[db performQuery:@"COMMIT"];
这是从数据库中删除某些内容的代码。当我尝试将此应用于我的滑动删除命令时:
-
(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)movieID
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//code goes here
}
}
它只是不想工作,我做错了什么?
The project I'm working on required me to use a sqlite database, and I've been trying to get swipe to delete to work on my tableView:
[self performSelectorOnMainThread:@selector(removeMovieFromCache:) withObject:[NSNumber numberWithInt:movieId] waitUntilDone:YES];
[db performSelectorOnMainThread:@selector(performQuery:) withObject:[NSString stringWithFormat:@"DELETE FROM movie WHERE id = %d", movieId] waitUntilDone:YES];
[db performSelectorOnMainThread:@selector(performQuery:) withObject:[NSString stringWithFormat:@"DELETE FROM new_movies WHERE new_movie_id = %d", movieId] waitUntilDone:YES];
[self removeMovieFromCache:movieId];
[db performQueryWithFormat:@"DELETE FROM movie WHERE id = %d", movieId];
[db performQueryWithFormat:@"DELETE FROM new_movies WHERE new_movie_id = %d", movieId];
[db performQuery:@"COMMIT"];
That's the code to get rid of something from my database. When I try to apply this to my swipe to delete command of:
-
(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)movieID
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//code goes here
}
}
It just doesn't want to work, what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 tableView 数据源中,尝试实现此操作:(
将“theTable”替换为您所说的表!)
In your tableView Data Source, try implementing this:
(replace "theTable" with whatever you've called your table!)