- (NSMutableArray *)orderArray {
if (!_orderArray) {
_orderArray = [NSMutableArray array];
}
return _orderArray;
}
- (NSMutableArray *)orderArray {
if (!_orderArray) {
_orderArray = [NSMutableArray array];
}
return _orderArray;
}
单例?
如果硬翻译
func orderArray()->NSMutableArray{
if _orderArray != nil {
_orderArray = NSMutableArray.array()
}
return _orderArray
}
swift点的话
// 单例类
class SharedObject {
static let sharedInstance = SharedObject()
}
// 使用
SharedObject.sharedInstance.doSomething()
你这个没错的话,应该是在 Objective-C 中的属性 get 方法。
其实 @Tr2e 差点就完全正确了,他的答案稍加修改就好了:
NO:
(PS: orders 才是更佳的命名)