iconImage is null

Hi all,

I have almost completed Ch19 and I am stuck.
At runtime I get basically a NullPointerException (I come from Java)

iconImage.image = UIImage(named: iconName)

is throwing a “null” exception.
I checked “iconName” by printing the name before that line and is fine; therefore iconImage is null, but I am lost

I am SW Developer/Integrator but not inside Xcode and not with Swift.

The problem appears when I click on “+” to add a new Checklist.

I will debug by putting some breakpoints, but, in the meantime, do you have any idea of what I could have missed/forgot?

Thanks
Marco

You specify a connection to a UIImageView on your storyboard with the following line in your code:

@IBOutlet weak var iconImage: UIImageView!

However, that is just sort of a “declaration” of a connection. Did you actually connect the outlet with the control in your storyboard? If you did not, then iconImage would be null at runtime since there is no control connected to the outlet.

Actually it was, but it was not a UIImageView, I do not know way, I think I selected the wrong item in the storyboard

This topic was automatically closed after 166 days. New replies are no longer allowed.