Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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中的ARC方法_Ios_Objective C_Swift_Automatic Ref Counting - Fatal编程技术网

Ios Swift中的ARC方法

Ios Swift中的ARC方法,ios,objective-c,swift,automatic-ref-counting,Ios,Objective C,Swift,Automatic Ref Counting,我能看到一个有趣的案例 它们有一个类ESTNearable,其属性名为zone // ENUM typedef NS_ENUM(NSInteger, ESTNearableZone ) { ESTNearableZoneUnknown = 0, ESTNearableZoneImmediate, ESTNearableZoneNear, ESTNearableZoneFar, }; // CLASS @interface ESTNearable : NSObject

我能看到一个有趣的案例

它们有一个类
ESTNearable
,其属性名为
zone

// ENUM
typedef NS_ENUM(NSInteger, ESTNearableZone ) {
   ESTNearableZoneUnknown = 0,
   ESTNearableZoneImmediate,
   ESTNearableZoneNear,
   ESTNearableZoneFar,
};

// CLASS
@interface ESTNearable : NSObject <NSCopying, NSCoding>
// ... 
@property (nonatomic, assign, readonly) ESTNearableZone zone;
// ...
@end
//枚举
typedef NS_枚举(NSInteger,ESTNearableZone){
ESTNearableZoneUnknown=0,
EstnealableZoneMiddate,
最近的区域,
EstnealableZonefar,
};
//阶级
@接口ESTNearable:NSObject
// ... 
@属性(非原子、赋值、只读)ESTNearableZone;
// ...
@结束
因此,当我尝试在Swift中使用此方法时,编译器失败并出现以下错误:

据我所知,存在某种编译器错误,出于某种原因,它认为我想使用
NSObject
-(struct\u NSZone*)zone OBJC\u ARC\u中的旧
zone
方法我可以毫无问题地使用该类的其他特定属性

由于我使用SDK,因此无法更改
区域
方法的名称。我相信我可以编写某种obj-c类别,在其中添加一些新方法,这些方法将返回原始方法的值,但我不想在我的项目中添加obj-c类

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


提前谢谢

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

我将此类别添加到桥接标题中。它工作得很好

#import <EstimoteSDK/EstimoteSDK.h>

@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

使用
-fno objc ARC
作为编译标志单独关闭该文件的ARC是否有效?谢谢您的建议,但我相信不允许禁用swift文件的ARC如果您将区域指定为ESTNearableZone,而不是让编译器决定,这可能有助于编译器选择正确的区域方法使用。我尝试了,但没有成功。
var zone = someNearable.nearableZone