SCLAlertView-Swift
SCLAlertView-Swift copied to clipboard
Unexpectedly found nil while unwrapping an Optional value.
Display alert view, dismiss. Display same alert view, tap "Done", unexpected nil. Didn't do too much digging but found in func buttonTapped
that btn.selector
is causing the error. Going to run through this and see why this attribute is getting set to nil after first dismissal. Any insights appreciated.
Okay, it looks like this is by design. When func hideView
is called, some clean up happens and all buttons' action
, target
, and selector
attributes are set to nil
. I understand your concern with not wanting to keep these strong references, but these alertViews have no effect on performance outside of animation. Maybe a clean up function could be implemented and handled by the presenting view or view controller. My solution for now is to comment out the settings of the buttons to nil inside of the hideView
function.
give my two cents.
Try not to keep the SCLAlertView() instance in the view controller and reuse it.
This fixed the issue I encountered.