Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift中调用Objective-C init方法不起作用_Ios_Objective C_Swift_Coordinates_Utm - Fatal编程技术网

Ios 在Swift中调用Objective-C init方法不起作用

Ios 在Swift中调用Objective-C init方法不起作用,ios,objective-c,swift,coordinates,utm,Ios,Objective C,Swift,Coordinates,Utm,我正在尝试使用此API转换坐标: 它有一个名为“GeoMethodicUTMConverter.h”的Objective-C类标题,其中包括: @interface GeodeticUTMConverter : NSObject @property (nonatomic, assign) UTMDatum utmDatum; + (CLLocationCoordinate2D)UTMCoordinatesToLatitudeAndLongitude:(UTMCoordinates)UTMCo

我正在尝试使用此API转换坐标:

它有一个名为“GeoMethodicUTMConverter.h”的Objective-C类标题,其中包括:

@interface GeodeticUTMConverter : NSObject

@property (nonatomic, assign) UTMDatum utmDatum;

+ (CLLocationCoordinate2D)UTMCoordinatesToLatitudeAndLongitude:(UTMCoordinates)UTMCoordinates;
+ (UTMCoordinates)latitudeAndLongitudeToUTMCoordinates:(CLLocationCoordinate2D)latitudeAndLongitudeCoordinates;

- (id)initWithDatum:(UTMDatum)datum;

- (CLLocationCoordinate2D)UTMCoordinatesToLatitudeAndLongitude:(UTMCoordinates)UTMCoordinates;
- (UTMCoordinates)latitudeAndLongitudeToUTMCoordinates:(CLLocationCoordinate2D)latitudeAndLongitudeCoordinates;
@end
以及一个实现“GeometricUtmConverter.m”:

我试图在我的swift代码中使用两个转换函数,因此我尝试在swift中创建一个实例,使用:

var instance = GeodeticUTMConverter()
但我得到一个“使用未解析标识符”错误。我看过很多SO帖子,以确保我的桥接标题是正确的。它正确地列在我的生成设置中,并且我以以下方式使用目标C头文件的名称:

#import "GeodeticUTMConverter.h"
所有的文件都在同一个文件夹中,所以我觉得我的Swift语法一定有问题。当我谈到这个问题时,有人知道我如何在swift中创建一个“UTMCoordinates”变量吗?它在GeometricUTMConverter.h文件中有一个typedef:

typedef double UTMDouble;
typedef unsigned int UTMGridZone;

typedef enum {
    kUTMHemisphereNorthern,
    kUTMHemisphereSouthern
} UTMHemisphere;

typedef struct {
    UTMDouble northing;
    UTMDouble easting;
    UTMGridZone gridZone;
    UTMHemisphere hemisphere;
} UTMCoordinates;

typedef struct {
    UTMDouble equitorialRadius;
    UTMDouble polarRadius;
} UTMDatum;

你的swift语法没有问题
let converter=GeodeticUTMConverter()
应该为您提供一个转换器实例。要获得一个
UTMCoordinates
实例,请使用:
let coordinates=UTMCoordinates(北距:0,东距:0,网格区:0,半球:UTMHemisphere(rawValue:0))
只需在干净的设置中进行测试。swift语法没有问题
let converter=GeodeticUTMConverter()
应该为您提供一个转换器实例。要获得一个
UTMCoordinates
实例,请使用:
let coordinates=UTMCoordinates(北距:0,东距:0,网格区:0,半球:UTMHemisphere(rawValue:0))
刚刚在一个干净的设置中进行了测试。
typedef double UTMDouble;
typedef unsigned int UTMGridZone;

typedef enum {
    kUTMHemisphereNorthern,
    kUTMHemisphereSouthern
} UTMHemisphere;

typedef struct {
    UTMDouble northing;
    UTMDouble easting;
    UTMGridZone gridZone;
    UTMHemisphere hemisphere;
} UTMCoordinates;

typedef struct {
    UTMDouble equitorialRadius;
    UTMDouble polarRadius;
} UTMDatum;