2016-11-29 57 views
0
let selector: Selector = #selector(getter: UIPrinter.displayName) 

我想這條線轉換爲SWIFT 2.2轉換選擇器2.2

這裏的功能fullcode

func indexFiles() { 

     let selector: Selector = #selector(getter: UIPrinter.displayName) 
     sections = Array(repeating: [], count: collation.sectionTitles.count) 



     if let sortedObjects = collation.sortedArrayFromArray(files, collationStringSelector: selector) as? [FBFile]{ 
      for object in sortedObjects { 
       let sectionNumber = collation.sectionForObject(object, collationStringSelector: selector) 
       sections[sectionNumber].append(object) 
      } 
     } 
    } 
+1

[引用吸氣劑是夫特3+特徵](https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md)。所以它可能需要一些包裝。 – user28434

回答

0

嘗試從UIPrinter比如VAR得到選擇。您可以使用

Selector類的公共init(_ str:String)初始值設定項。

let url = NSURL(fileURLWithPath: "file url ") 
    let printer = UIPrinter(URL:url) 
    let selector:Selector = Selector(printer.displayName)