-(void)bindStatement:(sqlite3_stmt *)statement withArg:(NSObject *)arg atIndex:(NSUInteger)argIndex
{
if ([arg isEqual:[NSNull null]]) {
sqlite3_bind_null(statement, argIndex);//Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'int'
} else if ([arg isKindOfClass:[NSNumber class]]) {
NSNumber *numberArg = (NSNumber *)arg;
const char *numberType = [numberArg objCType];
if (strcmp(numberType, @encode(int)) == 0) {
sqlite3_bind_int(statement, argIndex, [numberArg integerValue]);
} else if (strcmp(numberType, @encode(long long int)) == 0) {
sqlite3_bind_int64(statement, argIndex, [numberArg longLongValue]);
} else if (strcmp(numberType, @encode(double)) == 0) {
sqlite3_bind_double(statement, argIndex, [numberArg doubleValue]);
} else {
sqlite3_bind_text(statement, argIndex, [[arg description] UTF8String], -1, SQLITE_TRANSIENT);
}
答案 0 :(得分:0)
The index
parameter of all of the sqlite3_bind_xxx
functions expect its datatype to be int
, not NSUInteger
.
The simplest solution is to change the datatype of your argIndex
parameter from NSUInteger
to int
. Or convert argIndex
to an int
value when using it with the calls to the sqlite3_bind_xxx
functions.
It's always best to use the proper datatype for a given variable.