简体   繁体   中英

Objective-C parameter of incompatible type 'double *'

I have this method like so:

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

}

which gives me this warning:

Format specifies type 'double' but the argument has type 'double *'

and this is how I am calling it:

[self insertTracking:barcodeHolder deviceId:[[UIDevice currentDevice] name] latitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude Completetion:^(NSArray *results, NSError *error){

}];

and I get this error

Sending 'CLLocationDegrees' (aka 'double') to parameter of incompatible type 'double *'

the variable longitude and latitude are coming from CLLocation how do I pass them in a double? When I insert them as string they get inserted into my database as 0 PLEASE HELP, I dont understand what I am doing wrong.

Those parameters should be double , not double * , assuming they are input parameters. It's pretty rare to pass a primitive type by pointer, unless it's being used for in/out or out.

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

(note sure why you've got Id at the end of their names; that is confusing).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM