在苹果发布 Swift 语言之后,ReactiveCocoa 使用 Swift 进行了重写。该框架创建了一个桥用来连接 Swift 和 Objective-C API (ReactiveSwift 和 ReactiveObjC)。
示例代码:
extension ActionProtocol where Input: AnyObject, Output: AnyObject { func toRACCommand() -> RACCommand<Input, Output> } extension ActionProtocol where Input: OptionalProtocol, Input.Wrapped: AnyObject, Output: AnyObject { func toRACCommand() -> RACCommand<Input.Wrapped, Output> } extension ActionProtocol where Input: AnyObject, Output: OptionalProtocol, Output.Wrapped: AnyObject { func toRACCommand() -> RACCommand<Input, Output.Wrapped> } extension ActionProtocol where Input: OptionalProtocol, Input.Wrapped: AnyObject, Output: OptionalProtocol, Output.Wrapped: AnyObject { func toRACCommand() -> RACCommand<Input.Wrapped, Output.Wrapped> }