xcode - Swift fatal error while scrolling -


again.

i have problem little project.

it runs if try scroll down crashes!

the part of code fatal error this:

  func fontfordisplay(atindexpath indexpath: nsindexpath) -> uifont? {     if indexpath.section == 0 {         let familyname = familynames[indexpath.row]         let fontname = uifont.fontnamesforfamilyname(familyname).first! string         return uifont(name: fontname, size: cellpointsize)     } else {         return nil     } } 

can me?

thanks!

i guess casting failing, wrap in if let

if let fontname = uifont.fontnamesforfamilyname(familyname).first as? string{    return uifont(name: fontname, size: cellpointsize) } 

Comments