我有一个协议实现如下。
protocol DatabaseInjectable {
static func deriveObjectFromDBRow(row: [String]) -> Self? // Method - 1
static func collectAllObjectsForDatabaseAction(action: (Database) -> Void) -> [Self]? // Method - 2
}
我在这样的对应实施中取得了成功Method - 1
:
static func deriveObjectFromDBRow(row: [String]) -> Self? {
...
}
但我无法实现Method - 2
这样的:
static func collectAllObjectsForDatabaseAction(action: (WWDatabase) -> Void) -> [Self]? {
...
}
我收到这样的错误:
'Self' is only available in a protocol or as the result of a method in a class;
任何返回(它自己的类)的数组形式的 Self
帮助都会很好。