0

while trying to reload table the program giving BAD_EXCESS Signal.

In below code.

-(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;}
iosDev
  • 604
  • 3
  • 12
  • 28
  • where your textField in view? i.e in your Table??? – Paras Joshi May 22 '12 at 08:27
  • YES........textfield is in all the cell of tableview – iosDev May 22 '12 at 08:28
  • Please point out the where your app crashes and what the error message is. – David Rönnqvist May 22 '12 at 08:29
  • Hello try using NSzombieEnabled to get more details on the error. – Veer May 22 '12 at 08:30
  • thats it,it give BAD Excess because its not direct save data for only one raw and then reload table so i think you can save data in array or in coredata and when viewWillAppear,in this method reload Table but not at that time when user redit tableView objects .... ope this undesrtand dear.. :)but its BAD EXCESS bcoz of TextField is object of table and you reload table... – Paras Joshi May 22 '12 at 08:33
  • ok......i got some little idea .......thanks – iosDev May 22 '12 at 08:35
  • virendra in your xcode go to edit schema then in argument tab and inside Environmental Variable add a new variable by clicking + in bottom left name it NSzombieEnabled and check the check box and if you are using xcode 4.2 or above in Diagnostics tab check the enable Zombie object. this will enable your NSzombieEnabled then try to run you project – superGokuN May 22 '12 at 09:39
  • ok......after enabling i have to hit run ..........can you tell me the complete process ........ – iosDev May 22 '12 at 10:00

3 Answers3

1

enable zombie objects and it will tell you what error occured.

go to product>edit schems> enabl zombi objects

Saad
  • 8,857
  • 2
  • 41
  • 51
  • http://stackoverflow.com/questions/2190227/how-do-i-setup-nszombieenabled-in-xcode-4 – Saad May 22 '12 at 08:38
1

It seems you are not defining all your variables.

Check where value is defined and what its value is.

Also, perhaps you should first resign the responder of the text field and then reload the table view. Depending on your code, the text field whose first responder you resign might not exist any more after a table view reload.

Mundi
  • 79,884
  • 17
  • 117
  • 140
0

You are getting BAD_EXCESS in this line... For more explanation post code of IntelligentPillBoxAppDelegate class

appdelegate.strip1_detail = [pillboxDb get_detail_for_din:value];
dasdom
  • 13,975
  • 2
  • 47
  • 58
kamlesh
  • 3
  • 2