本文介绍了估计近义词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

我正在尝试找到附近的附近.我正在构造一个switch语句,以检查它的近,中间,远等.我正在Swift中工作.

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
 }

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

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 ?

推荐答案

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

I had the same problem. Here is my SO question

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

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

之后,我只在 Swift

var zone = someNearable.nearableZone

这篇关于估计近义词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:28