如何将此代码从Swift转换为Objective C

时间:2016-07-15 19:22:13

标签: objective-c swift

private var distance: Double {
    return fabs(max - min)
}

如何用Objective C语言定义此变量。

1 个答案:

答案 0 :(得分:2)

在您的.m文件中:

@interface MyClass ()
@property (nonatomic, assign, readonly) double distance;
@end

@implementation MyClass

-(double)distance {
    return fabs(max - min);
}

@end