Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 分配给';双*';来自不兼容类型';双倍';_Ios_Database_Sqlite_Double - Fatal编程技术网

Ios 分配给';双*';来自不兼容类型';双倍';

Ios 分配给';双*';来自不兼容类型';双倍';,ios,database,sqlite,double,Ios,Database,Sqlite,Double,我有一个SQLite数据库,其中有一些double类型的字段,我必须提取这个值并将它们放在一个实例变量中,但是我得到了这个错误 Assigning to 'double *' from incompatible type 'double' 代码如下: 数据库表 @interface DatabaseTable : NSObject { sqlite3 * database; } //........ @property (nonatomic, assign)do

我有一个SQLite数据库,其中有一些double类型的字段,我必须提取这个值并将它们放在一个实例变量中,但是我得到了这个错误

  Assigning to 'double *' from incompatible type 'double'
代码如下:

数据库表

   @interface DatabaseTable : NSObject {
sqlite3 * database;

   }

   //........
   @property (nonatomic, assign)double *latitude; //latitude is a field of type double
   @property (nonatomic, assign)double *longitude; //longitude is a field of a type double

   @end
DatabaseTable.m

   //.....
    while (sqlite3_step(statement) == SQLITE_ROW) {

       DatabaseTable * rowTable =[[ChinaDatabaseTable alloc]init];
           //.......

           rowTable.latitude =sqlite3_column_double(statement, 15); //here the error
           rowTable.longitude =sqlite3_column_double(statement, 16);//here the error

           //.....
     }

我能做什么?

您不需要在int、float、bool等基本类型之前加上
*

因此,更改代码如下:

   @property (nonatomic, assign)double latitude; //latitude is a field of type double
   @property (nonatomic, assign)double longitude; //longitude is a field of a type double
如果需要创建指针变量,那么代码就可以了

但是您不能直接为基元类型的指针值赋值

如果需要分配地址值,则需要执行以下操作:

double temp = sqlite3_column_double(statement, 15);
rowTable.latitude = &temp;

您不需要在int、float、bool等基本类型之前加上
*

因此,更改代码如下:

   @property (nonatomic, assign)double latitude; //latitude is a field of type double
   @property (nonatomic, assign)double longitude; //longitude is a field of a type double
如果需要创建指针变量,那么代码就可以了

但是您不能直接为基元类型的指针值赋值

如果需要分配地址值,则需要执行以下操作:

double temp = sqlite3_column_double(statement, 15);
rowTable.latitude = &temp;
也许看看这个?也许看看这个?