SCLAlertView-Swift icon indicating copy to clipboard operation
SCLAlertView-Swift copied to clipboard

Unexpectedly found nil while unwrapping an Optional value.

Open seth-folley opened this issue 7 years ago • 2 comments

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.

seth-folley avatar Mar 25 '17 05:03 seth-folley

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.

seth-folley avatar Mar 25 '17 05:03 seth-folley

give my two cents.

Try not to keep the SCLAlertView() instance in the view controller and reuse it.

This fixed the issue I encountered.

pai911 avatar Aug 15 '19 05:08 pai911