Objective c 隐式转换丢失整数精度:';整数';(又称无符号长字符)到';int';
所有Objective c 隐式转换丢失整数精度:';整数';(又称无符号长字符)到';int';,objective-c,sqlite,Objective C,Sqlite,所有sqlite3\u bind\u xxx函数的index参数期望其数据类型为int,而不是NSUInteger 最简单的解决方案是将argIndex参数的数据类型从NSUInteger更改为int。或者在调用sqlite3\u bind\u xxx函数时,将argIndex转换为int值 对于给定的变量,最好总是使用正确的数据类型。这是Objective-C,而不是Swift。可能是重复的。 -(void)bindStatement:(sqlite3_stmt *)statement wit
sqlite3\u bind\u xxx
函数的index
参数期望其数据类型为int
,而不是NSUInteger
最简单的解决方案是将argIndex
参数的数据类型从NSUInteger
更改为int
。或者在调用sqlite3\u bind\u xxx
函数时,将argIndex
转换为int
值
对于给定的变量,最好总是使用正确的数据类型。这是Objective-C,而不是Swift。可能是重复的。
-(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);
}