Estimote Nearables

倖福魔咒の 提交于 2019-12-07 10:47:15

问题


All,

I am trying to find the proximity of a nearable. I am constructing a switch statement to check if its near, intermidetate, far etc. I am working in Swift.

I have ranged my nearable and I am in a delegate method :

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

When I try and get Zone it doesn't find it, so nearable.zone is not found - I don't know what is wrong. Any ideas ?


回答1:


I had the same problem. Here is my SO question

Seems like Swift compiler doesn't want to use zone method as for some reason it assumes that you want to call zone method from NSObject, which returns NSZone * struct and can not be used in ARC environment.

I fixed this problem with introducing a category with one new method which returns value from the old one.

I Added this category to Bridging Header. It worked fine.

#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

After that I just used nearableZone method in Swift

var zone = someNearable.nearableZone


来源:https://stackoverflow.com/questions/29386188/estimote-nearables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!