0

在尝试重新加载表时,程序给出了 BAD_EXCESS 信号。

在下面的代码中。

-(void)textFieldDidEndEditing:(UITextField *)textField {
    NSLog(@"%d",textField.tag);
    if (textField.tag == 2) {
            IntelligentPillBoxAppDelegate *appdelegate = (IntelligentPillBoxAppDelegate *)[[UIApplication sharedApplication]delegate];
            appdelegate.strip1_detail = [pillboxDb get_detail_for_din:value];

            [table reloadData];
    }
    [textField resignFirstResponder];
}

+(NSMutableArray*)get_detail_for_din:(int) din{
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *strDestPath = [NSString stringWithFormat:@"%@/samplepillbox1.sqlite",[arrDocPath objectAtIndex:0]];

//IntelligentPillBoxAppDelegate *appdelegate = (IntelligentPillBoxAppDelegate *)[[UIApplication sharedApplication]delegate];
//appdelegate.strip1_detail = [[NSMutableArray alloc]init];
NSMutableArray *strip1_detail = [[NSMutableArray alloc]init];
sqlite3 *db;
if(sqlite3_open([strDestPath UTF8String], &db)==SQLITE_OK)

{

    NSString *query = [NSString stringWithFormat:@"select * from maintable_master where din =%d ",din];

    void* v;
    char* err_msg;
    sqlite3_stmt *studentStmt;

    if(sqlite3_prepare_v2(db, [query UTF8String], -1, &studentStmt, &err_msg)==SQLITE_OK)
    {
        while (sqlite3_step(studentStmt)==SQLITE_ROW) {

            int din = sqlite3_column_int(studentStmt, 0);
            NSString *brandname = [NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 1)];
            NSString *fullname = [NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 2)];
            NSString *strength = [NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 3)];
            NSString *medicationtype =[NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 4)];
            NSString *presciptionid= [NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 5)];
            //float marks = sqlite3_column_double(studentStmt, 2);

            //pillbox *st = [[pillbox alloc]init];
            //st.Din = sno;
            //st.Name = sname;

            //NSLog(@"%@",st);

            Strip_items *si = [[Strip_items alloc]init];
            si.Din = din;
            si.BrandName = brandname;
            si.FullName = fullname;
            si.Strength = strength;
            si.MedicationType = medicationtype;
            si.PresciptionID = presciptionid; 
            NSLog(@"%@",si.BrandName);
            NSLog(@"%d",si.Din);
            NSLog(@"%@",si.FullName);
            NSLog(@"%@",si.Strength);
            NSLog(@"%@",si.MedicationType);
            NSLog(@"%@",si.PresciptionID);



            [strip1_detail addObject:si];
        }

    }

}
return strip1_detail;}
4

3 回答 3

1

启用僵尸对象,它会告诉你发生了什么错误。

转到产品>编辑方案>启用僵尸对象

于 2012-05-22T08:28:22.253 回答
1

似乎您没有定义所有变量。

检查在哪里value定义以及它的值是什么。

另外,也许您应该退出文本字段的响应者,然后重新加载表格视图。根据您的代码,您辞职的第一响应者的文本字段在重新加载表视图后可能不再存在。

于 2012-05-22T08:35:47.050 回答
0

IntelligentPillBoxAppDelegate你在这一行得到了 BAD_EXCESS ......有关更多解释类的邮政编码

appdelegate.strip1_detail = [pillboxDb get_detail_for_din:value];
于 2012-05-22T08:46:45.883 回答