Inaccessible ARC Methods in Swift

I was able to see an interesting case using Estimated SDK Estimation

They have a class ESTNearablewith a property 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

Therefore, when I try to use this method in Swift , the compiler does not cope with this error: enter image description here

As I understand it, there is some kind of compiler error, and for some reason, it believes that I want to use the old method zonefrom NSObject - (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;. I can use other specific properties of this class without any problems.

As I use the SDK, I cannot change the name of the method zone. I believe that I can write some kind of obj-c category, add some new method there that will return the value of the original one, but I do not want to add obj-c classes to my project.

, , , zone ?

!

+3
1

. . - , .

. .

#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

nearableZone Swift

var zone = someNearable.nearableZone
0

All Articles