iOS Swift:用于条件绑定的初始化程序必须具有可选类型,而不是'()-> String?

时间:2018-10-04 13:35:18

标签: ios swift xcode

用于条件绑定的初始化程序必须具有可选类型,而不是'()->字符串?

如何处理此错误?

enter image description here 代码:

func loadViewFromNib() -> UIView? {
    let xibName = getXibName()

    let bundle = Bundle(for: type(of: self))
    let nib = UINib(nibName: xibName!, bundle: bundle)
    return nib.instantiate(
        withOwner: self,
        options: nil).first as? UIView
}

func getXibName() -> String? {
    return nil
}

1 个答案:

答案 0 :(得分:0)

感谢OOPer的评论:

Xcode->产品->清理生成文件夹

enter image description here