Reputation: 1067
i have a dynamically made prototype:
typedef double ICEDouble;
-(BOOL) getPosition:(SyDRpcInterfacePositionType)type longitude:(ICEDouble *)longitude latitude:(ICEDouble *)latitude;
and i would call it so, because i have no plan, how to do it in the right way:
NSNumber* longitudeReturn;
NSNumber** latitudeReturn;
[prx getPosition:SyDRpcInterfaceMAPMATCHED longitude:longitudeReturn latitude:latitudeReturn];
the compiler says:
warning: passing argument 2 of 'getPosition:longitude:latitude:' from incompatible pointer type
warning: passing argument 3 of 'getPosition:longitude:latitude:' from incompatible pointer type
not really surprising, but can anyone please tell me how to do it right ? maybe with a little explanation for a beginner ?
Upvotes: 0
Views: 833
Reputation: 1067
and on this construct ?
SyDRpcInterfaceNavInfos** datenSammlung;
//-(BOOL) getGuidanceInfos:(SyDRpcInterfaceNavInfos **)infos;
if([prx getGuidanceInfos:&datenSammlung]) {//further activities}
wether if i let the &, nor if i leave the end because of the extra pointer-*, the programm quits with both constellations at here. the SyDRpcInterfaceNavInfos is a struct.
Upvotes: 0
Reputation: 816580
Several things:
ICEDouble
, you provide NSNumber
.NSNumber** latitudeReturn
, you define a pointer to a pointer.So I guess it should be
ICEDouble* longitudeReturn;
ICEDouble* latitudeReturn;
[prx getPosition:SyDRpcInterfaceMAPMATCHED longitude:longitudeReturn latitude:latitudeReturn];
Upvotes: 2
Reputation: 28600
Assuming ICEDouble
is typedef'd to `double', it looks like the method you are calling has two 'out' parameters. It should be called like this:
double lat, long;
[prx getPosition:SyDRpcInterfaceMAPMATCHED longitude:&long latitude:&lat];
This is a common idiom when a method needs to return multiple values, without object overhead. If needed, you can then convert these to NSNumber
s if you need them, via:
NSNumber * nLatitude = [NSNumber numberWithDouble:lat];
NSNumber * nLongitude = [NSNumber numberWithDouble:long];
Check the return type of getPosition:
though. If it returns a BOOL
you will want to check the result before using the returned values. Otherwise, lat
and long
will represent garbage values.
Upvotes: 3