user836026
user836026

Reputation: 11340

How to create instance of struct in Objective-C that was defined in C file

In Xcode I have C classes that contains the following definition:

typedef struct {
    double x;
    double y;
    double z;
    CoordUnit unit;
} YG
#define YGMeterPoint(x,y,z) __YGPointWithUnit(x,y,z,METER)

This used as follows in C:

//Declares origin point and translated point
YGPoint point = YGMeterPoint(994272.661, 113467.422);

//Converts point in Lambert Zone 1 to WGS84
point = YGPointConvertWGS84(point, LAMBERT_I)

//Convert to Degree
point = YGPointToDegree(point);

printf("Lat:%.9f - Lon:%.9f", point.y, point.x);

But I would like call it using Objective-C in Xcode. How to do that?

Upvotes: 0

Views: 81

Answers (1)

Rob Sanders
Rob Sanders

Reputation: 5347

Like @Martin R said, normally I can't see why you would need/want to do this however this article explains how to do it. Look at Example 2.

Upvotes: 1

Related Questions