2015-03-29 23 views
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 
+0

related: [Bir protokole uyan sınıf dizisini bildirme] (http://stackoverflow.com/a/28691376/3804019) – rintaro

cevap

2

enter image description here

Gerçek senaryo ı varış olması Gördüğünüz gibi bu çabukluk parçası uygulanamaz. (Xcode 6.3 beta 4)

İlgili konular