在可编辑的可用表单中移动某些行后出错

我想在可编辑的UITableView中移动一些行后保存到数据库, 但发生错误 我找不到错误的原因。请告诉我关于我的代码。谢谢!!

我的代码:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
           return indexPath.section == 0 && indexPath.row < items.count;        
} 

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
  toIndexPath:(NSIndexPath *)toIndexPath {

        isReOrderNoteList= YES;

        NSString *rowContent = [items objectAtIndex:fromIndexPath.row];
        [items removeObjectAtIndex:fromIndexPath.row];
        [items insertObject:rowContent atIndex:toIndexPath.row];
 }

//I'm using UIButton instead of Navigation barbutton.
- (IBAction)EditTable:(id)sender{

       f(TableView.editing)
        {
            if(isReOrderNoteList)
            {    
                [super setEditing:NO animated:NO]; 
                [TableView setEditing:NO animated:NO];
                [btn_Edit setTitle:@"Edit" forState:UIControlStateNormal];

                FMDatabase *dbS = [FMDatabase databaseWithPath:dbPath];     
                [dbS open]; 

                NSInteger tmp = 1; 
                NSLog(@" [self.items count] : %d", [ items count]);  **// Print 6 !!.** 

                for (NSInteger i = 0; i< [items count]; i++) {

                    Note *list = [[Note alloc] init];
                    list = [items objectAtIndex:i]; 
                    NSLog(@" list.itle : %@", list.title);  **//Error occurred at this line.**
                    NSLog(@" list.IDX : %d", list.IDX);
                    [dbS executeUpdate:@"Update test set sort_seq = ? where  idx = ? ", [NSNumber numberWithInt:tmp], [NSNumber numberWithInt:list.IDX]]; 
                    [list release];
                    tmp++; 
                }
                [dbS close];      
            }

            //Re-init 
            isReOrderNoteList = NO; 
        }
        else
        {
            [super setEditing:YES animated:YES]; 
            [TableView setEditing:YES animated:YES];      
            [btn_Edit2 setTitle:@"Done" forState:UIControlStateNormal]; 
        }

}

错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteNotification title]: unrecognized selector sent to instance 0x892b550'
*** First throw call stack:
0
额外 编辑
意见: 1
尝试应用中断点或启用僵尸。您的错误表明您要么调用未知的函数,要么调用未定义的函数
额外 作者 superGokuN,

2 答案

您可以在代码的末尾释放注释,而不必在“items”数组上进行

    Note *list = [[Note alloc] init];
    list = [items objectAtIndex:i]; 
    NSLog(@" list.itle : %@", list.title);  **//Error occurred at this line.**
    NSLog(@" list.IDX : %d", list.IDX);
    [dbS executeUpdate:@"Update test set sort_seq = ? where  idx = ? ", [NSNumber numberWithInt:tmp], [NSNumber numberWithInt:list.IDX]]; 
    [list release];

它应该是

    Note *list = [items objectAtIndex:i]; 
    NSLog(@" list.itle : %@", list.title);  **//Error occurred at this line.**
    NSLog(@" list.IDX : %d", list.IDX);
    [dbS executeUpdate:@"Update test set sort_seq = ? where  idx = ? ", [NSNumber numberWithInt:tmp], [NSNumber numberWithInt:list.IDX]]; 
1
额外
谢谢!〜你的答案是我想要的。
额外 作者 hyekyung,
EM?第一部分修改后,我的代码运行良好。 ^^谢谢!
额外 作者 hyekyung,
第二部分也根据你的回复进行修改。 :-)
额外 作者 hyekyung,
@hyekyung对不起,你的代码的第一部分是正确的,在你再次插入数组之前它不会被释放,:)
额外 作者 adali,
你不是第二部分吗?
额外 作者 adali,
所以,我想也许第二部分工作:)
额外 作者 adali,

我认为它的Alloc初始化问题...所以试着分配你的uitableview中使用的“rowContent”和其他字符串

0
额外