【发布时间】:2018-08-24 11:47:29
【问题描述】:
我有一个旧代码库,其中包含用 Objective-C 编写的代码。我正在添加一个用 Swift 编写的新类,它必须符合 Objective-C 中定义的现有协议。
如何确保我的 Swift 类正确实现了 Objective-C 协议中定义的方法?
//In Obj-C
@protocol OBJCLocationObserver <NSObject>
- (void)didUpdateLocationWithModel:(nullable Model *)locationModel
lastLocation:(CLLocationCoordinate2D)lastLocation;
@end
//In Swift
extension SwiftLocationManager : OBJCLocationObserver
{
public func didUpdateLocation(with model: Model?, lastLocation: CLLocationCoordinate2D) {
// How to verify this function signature is actually conforming to the Obj-C protocol and is not a new method?
}
}
【问题讨论】:
标签: objective-c swift swift4 protocols ios11