func fontForDisplay(atIndexPath indexPath : NSIndexPath) -> UIFont? {
if indexPath.section == 0 {
let familyName = familyNames[indexPath.row]
let fontName = UIFont.fontNamesForFamilyName(familyName).first as String!
return UIFont(name: fontName, size: cellPointSize)
}else {
return nil
}
}
错误消息:FontName为零 但我不知道如何解决它
我需要帮助。感谢
答案 0 :(得分:1)
你可以使用后卫。它允许您专注于有效语句并使用fontName的可选绑定:
func fontForDisplay(atIndexPath indexPath : NSIndexPath) -> UIFont? {
guard indexPath.section == 0 else { return nil }
let familyName = familyNames[indexPath.row]
guard let fontName = UIFont.fontNamesForFamilyName(familyName).first else { return nil }
return UIFont(name: fontName, size: cellPointSize)
}
答案 1 :(得分:0)
试试这个:
<a rel="next" href="http://localhost/wordpress/?p=369">
<span class="fa fa-chevron-left nav-icn-L"></span>
<span class="meta-nav">Welcome</span>
</a>
答案 2 :(得分:0)
当我收到此错误时,是因为有一个IBObject未被调用到coreesponding viewcontroller .swift。
我建议你按住Ctrl键点击所有对象,然后调出一个黑色菜单,所有对象关联,有时你可以在同一个IBObject上对.swift文件进行2次对象调用,虽然你已经删除了它在代码中,它仍然认为它在故事板中!
我希望这会有所帮助