Код: Выделить всё
import SceneKit
let action = SCNAction.run { _ in
print("foo")
}
< /code>
Вот мой прогресс: < /p>
protocol RLAction {}
struct RLCallbackAction: RLAction {}
extension RLAction where Self == RLCallbackAction {
static func run() -> RLCallbackAction {
return RLCallbackAction()
}
}
< /code>
Тогда это работает < /p>
let action: RLAction = .run()
< /code>
Но это не удается: < /p>
let action = RLAction.run()
< /code>
С сообщением об ошибке: < /p>
Referencing static method 'run()' on 'RLAction' requires the types 'Self' and 'RLCallbackAction' be equivalent
< /code>
Я полностью понимаю, что могу просто сделать: < /p>
let action = RLCallbackAction.run()
Код: Выделить всё
public protocol RLActionImplementation {
// ...
}
public struct RLAction {
var duration: TimeInterval
let implementation: Implementation
}
public struct RLAggregationActionImplementation: RLActionImplementation {
public enum Aggregation {
case sequence
case group
}
// ERROR here
public let actions: [RLAction]
public let aggregation: Aggregation
< /code>
Приведенная выше приводит к этой ошибке: < /p>
Property declares an opaque return type, but has no initializer expression from which to infer an underlying type
Подробнее здесь: https://stackoverflow.com/questions/797 ... y-in-swift