Objective-C 类型不兼容的参数 'double *'
Objective-C parameter of incompatible type 'double *'
我有这样的方法:
-(void)insertTracking:(NSString *)tag deviceId:(NSString *)phone latitude:(double *)latitudeId longitude:(double *)longitudeId Completetion:(void (^) (NSArray * result,NSError * error))completion{
}
这给了我这个警告:
Format specifies type 'double' but the argument has type 'double *'
我是这样称呼它的:
[self insertTracking:barcodeHolder deviceId:[[UIDevice currentDevice] name] latitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude Completetion:^(NSArray *results, NSError *error){
}];
我收到这个错误
Sending 'CLLocationDegrees' (aka 'double') to parameter of incompatible type 'double *'
变量经度和纬度来自 CLLocation 如何将它们传递给双精度值?当我将它们作为字符串插入时,它们会作为 0 插入到我的数据库中,请帮助,我不明白我做错了什么。
这些参数应该是 double
,而不是 double *
,假设它们是输入参数。通过指针传递原始类型是非常罕见的,除非它被用于 in/out 或 out.
-(void)insertTracking:(NSString *)tag
deviceId:(NSString *)phone
latitude:(double)latitudeId
longitude:(double)longitudeId
Completetion:(void (^) (NSArray * result,NSError * error))completion;
(请注意为什么他们的名字末尾有 Id
;这很令人困惑)。
我有这样的方法:
-(void)insertTracking:(NSString *)tag deviceId:(NSString *)phone latitude:(double *)latitudeId longitude:(double *)longitudeId Completetion:(void (^) (NSArray * result,NSError * error))completion{
}
这给了我这个警告:
Format specifies type 'double' but the argument has type 'double *'
我是这样称呼它的:
[self insertTracking:barcodeHolder deviceId:[[UIDevice currentDevice] name] latitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude Completetion:^(NSArray *results, NSError *error){
}];
我收到这个错误
Sending 'CLLocationDegrees' (aka 'double') to parameter of incompatible type 'double *'
变量经度和纬度来自 CLLocation 如何将它们传递给双精度值?当我将它们作为字符串插入时,它们会作为 0 插入到我的数据库中,请帮助,我不明白我做错了什么。
这些参数应该是 double
,而不是 double *
,假设它们是输入参数。通过指针传递原始类型是非常罕见的,除非它被用于 in/out 或 out.
-(void)insertTracking:(NSString *)tag
deviceId:(NSString *)phone
latitude:(double)latitudeId
longitude:(double)longitudeId
Completetion:(void (^) (NSArray * result,NSError * error))completion;
(请注意为什么他们的名字末尾有 Id
;这很令人困惑)。