【问题标题】:Estimote Nearables估计近邻
【发布时间】:2015-06-05 19:52:47
【问题描述】:

全部,

我试图找到一个近邻。我正在构建一个 switch 语句来检查它是否接近、中间、远等。我在 Swift 中工作。

我已经调整了我的近亲,我在委托方法中:

 func nearableManager(manager: ESTNearableManager!, didRangeNearable nearable: ESTNearable!) {
    self.nearable = nearable
 }

当我尝试获取 Zone 时,它​​没有找到它,所以没有找到 nearable.zone - 我不知道出了什么问题。有什么想法吗?

【问题讨论】:

  • “未找到”是什么意思,是0吗? (即 ESTNearableZoneUnknown)

标签: swift ibeacon estimote


【解决方案1】:

我遇到了同样的问题。这是我的SO question

似乎 Swift 编译器不想使用 zone 方法,因为出于某种原因它假定您要从 NSObject 调用 zone 方法,该方法返回 NSZone * 结构并且不能在 ARC 中使用环境。

我通过引入一个新方法来解决这个问题,该方法从旧方法返回值。

我将此类别添加到桥接头。效果很好。

#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

之后我只是在 Swift

中使用了nearableZone 方法
var zone = someNearable.nearableZone

【讨论】:

    猜你喜欢
    • 2016-06-18
    • 2015-01-19
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 2011-03-07
    相关资源
    最近更新 更多