Swift中ARC不可用的方法

我能够使用Estimote nearables SDK看到一个有趣的案例

他们有一个ESTNearable类,名为zone

 // ENUM typedef NS_ENUM(NSInteger, ESTNearableZone ) { ESTNearableZoneUnknown = 0, ESTNearableZoneImmediate, ESTNearableZoneNear, ESTNearableZoneFar, }; // CLASS @interface ESTNearable : NSObject  // ... @property (nonatomic, assign, readonly) ESTNearableZone zone; // ... @end 

因此,当我尝试在Swift中使用此方法时,编译器会因该错误而失败: 在此处输入图像描述

据我所知,存在某种编译器错误,并且由于某种原因它认为我想使用来自NSObjectzone方法- (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE; 我可以毫无问题地使用该类的其他特定属性。

当我使用SDK时,我无法更改zone方法的名称。 我相信我可以写一些obj-c类,在那里添加一些新方法,它将返回原始方法的值,但我不想在我的项目中添加obj-c类。

是否有可能从swift调用此方法,因为我相信将为类实例调用正确的zone方法?

提前致谢!

在这里,我发现了同样的问题。 我在那里回答得更深。 我找不到更好的东西,所以我继续我的旧假设。

我在Bridging Header中添加了这个类别。 它工作正常。

 #import  @interface ESTNearable (Ex) /// Solving the compiler problem that "zone" method is unavailable in Swift @property (readonly) ESTNearableZone nearableZone; @end // Implementation @implementation ESTNearable (Ex) - (ESTNearableZone)nearableZone { return self.zone; } @end 

之后我在Swift中使用了nearableZone方法

 var zone = someNearable.nearableZone