-(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);
}
Asked
Active
Viewed 412 times
-2

rmaddy
- 314,917
- 42
- 532
- 579

Aditya Raj Gupta
- 51
- 1
- 2
- 4
-
3That's Objective-C, not Swift. – Martin R Oct 20 '16 at 19:22
-
1Possible duplicate of [objective c implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' warning](http://stackoverflow.com/questions/16918826/objective-c-implicit-conversion-loses-integer-precision-nsuinteger-aka-unsig). – Martin R Oct 20 '16 at 19:24
1 Answers
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.

rmaddy
- 314,917
- 42
- 532
- 579