Swift: unwrapping cause swift compile slowly

前端 未结 2 438
遥遥无期
遥遥无期 2021-01-05 15:00

In func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{

this line of code makes swift compile

2条回答
  •  猫巷女王i
    2021-01-05 15:11

    Yes, I filed a bug report (17585851) on this slow compilation issue, and you should do the same; the more clear use cases Apple is sent, the better. My slow code was several occurrences of this form:

    let title = obj.valueForProperty(MPMediaItemPropertyTitle) as? String
    self.titles += title ? title! : ""
    

    (which, as you can see, is doing nil testing / unwrapping). It was cumbersome but not difficult for me to work around the problem by doing the same thing in a different way, and you should do likewise. But file that bug report first!

提交回复
热议问题