Objective-C参数不兼容类型' double *'

时间:2015-09-28 13:00:45

标签: ios objective-c cllocationmanager

我有这样的方法:

    -(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如何将它们传递给double?当我将它们作为字符串插入时,它们会被插入到我的数据库中0请帮助,我不明白我做错了什么。

1 个答案:

答案 0 :(得分:3)

这些参数应该是double,而不是double *,假设它们是输入参数。通过指针传递基本类型是非常罕见的,除非它被用于输入/输出或输出。

-(void)insertTracking:(NSString *)tag
             deviceId:(NSString *)phone
             latitude:(double)latitudeId
            longitude:(double)longitudeId
         Completetion:(void (^) (NSArray * result,NSError * error))completion;

(请注意为什么你的名字末尾有Id;这很令人困惑。)