I have a SQLite database with some fields of type double and I have to extract this value and put them in an instance variable, but I get this error
Assigning to 'double *' from incompatible type 'double'
this is the code:
DatabaseTable.h
@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
//.....
}
What can I do?
You don’t need to put a
*before the primitive types like int, float, bool etc.So change the code like:
If you need to create a pointer variable then your code is ok.
But you can’t assign values directly to a pointer value for the primitive types.
If you need to assign the address value, you need to do like: