此代码在 iphone、ipad 模拟器xcode 4.5
和xcode 4.6
.Also 中完美地与设备一起调试xcode 4.5
。但是当我尝试在 xcode 4.6.2 中调试设备时,会显示此错误。
这是查询
NSString *insertQuery=[NSString stringWithFormat:@"Insert into %@ (ID,Question,Answer,Option1,Option2,Option3,Explanation,ImageName,Used) values(%d,'%@','%@','%@','%@','%@','%@','%@','%@')",table,[[d objectForKey:@"ID"]intValue],[d objectForKey:@"Question"],[d objectForKey:@"Answer"],[d objectForKey:@"Option1"],[d objectForKey:@"Option2"],[d objectForKey:@"Option3"],[d objectForKey:@"Explanation"],[d objectForKey:@"ImageName"],@"N"];
NSLog(@"insert query-%@",insertQuery);
[database executeNonQuery:insertQuery];
这是显示 EXC_BAD_ACCESS 错误的代码
- (BOOL)executeNonQuery:(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)]; //This line shows error.
}
va_end(args);
BOOL success = [self executeNonQuery:sql arguments:argsArray];
[argsArray release];
return success;
}