问题
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