ios - Issue with setting image UILabel swift - found nil while unwrapping optional -


code looks this:

    lazy var placelabel: uilabel = {         let label = uilabel()         label.backgroundcolor = uicolor(patternimage: uiimage(named: "placelabel")!)         label.translatesautoresizingmaskintoconstraints = false          return label     }() 

i'm not sure why when input label.backgroundcolor() program can't run , breaks on line.

"fatal error: unexpectedly found nil while unwrapping optional value"

when remove , continue setup seems run fine. i've seen other comments on issues saying view isn't setup when command called i'm pretty doing exact same thing buttons , whatnot , it's working fine.

any idea why happening?

thanks

in line, uicolor(patternimage: uiimage(named: "placelabel")!), forcing unwrapping of uiimage object using !. if no image named "placelabel" exists in project, app crash, trying unwrap nil.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -