The code I am using for executing the query is as below:
NSString *score_query = @"Insert into tbl_assessment (Question,Answer,Option1,Option2,Option3,Explanation,Used,ImageName,Reference) values ('All of the following questions would be asked in a lifestyle questionnaire except:','Do you feel any pain in your chest when you perform physical activity?','Does your occupation cause you anxiety (mental stress)?','Does your occupation require extended periods of sitting?','Do you partake in any recreational activities (golf, tennis, skiing, etc.)?','NULL','N','NULL','NULL')";
NSLog(@"%@",score_query);
[database executeQuery:score_query];
I have generated this query dynamically. But I have added the query directly to the string. But when I tried to execute this insert query, app crashes on below function:
- (NSArray )executeQuery:(NSString )sql, ... {
va_list args;
va_start(args, sql);
NSMutableArray *argsArray = [[NSMutableArray alloc] init];
NSUInteger i;
for (i = 0; i < [sql length]; ++i)
{
if ([sql characterAtIndex:i] == '?')
[argsArray addObject:va_arg(args, id)];
}
va_end(args);
NSArray *result = [self executeQuery:sql arguments:argsArray];
[argsArray release];
return result;
}
The dropbox for the classes I am using for database operation is given below: https://www.dropbox.com/s/c4haxqnbh0re41c/Archive%202.zip?dl=0
I have already referred the below link but can't understand. Sqlite shows EXC_BAD_ACCESS in ios SDK