5
'da çalışmaz Sorun şu ki, tip proto.type ise sınıf yöntemlerini çağırmıyorum. Bunu başarabilecek alternatif bir model var mı? [SomeProtocol.Type] ve ben let dizeleri gerçekleştirmek istediğiniz: [dize] = arr.map {$ 0.str}Protokol türündeki üyelere erişim Swift
protocol SomeProtocol: class {
static var str: String { get }
static func value() -> Int
}
class SomeClass: SomeProtocol {
static var str: String = "SomeClass"
static func value() -> Int {
return 1
}
}
let protocolType: SomeProtocol.Type = SomeClass.self
println(protocolType.str) // compile error
println(protocolType.value()) // compile error
related: [Bir protokole uyan sınıf dizisini bildirme] (http://stackoverflow.com/a/28691376/3804019) – rintaro