Why does this code:
if Note1Math.stringValue == "" {
TxtFilled = 0
}else{
TxtFilled = 1
}
give this error?:
2015-06-18 20:20:17.633 Office[41763:430750] Failed to connect (Note1) outlet from (Office.ViewController) to (NSTextField): missing setter or instance variable.
fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
This part of the message:
does not come from that code. It comes from the loading of a NIB or storyboard. Presumably, you had named an outlet
Note1
at one time, connected it in the NIB or storyboard, and then renamed it toNote1Math
in the code without fixing the NIB/storyboard.Then, later, when you accessed
Note1Math
, it wasnil
(because it was not connected in the NIB/storyboard). That caused the second message:The solution is to go into the NIB or storyboard, disconnect the outlet with the old name, and reconnect the outlet.