Using dispatch_async with self

You should condition spinning off this action on the non-nullity, not test for it after you’ve already initiated it:

if let hostView = self.hostViewController?.view {
    DispatchQueue.main.async {
         hostView.addSubview(self.commandField)
    }
} else {
    // handle nil hostView 
}

You should never unwrap an optional outside of an if let, or testing it first. Doing this should also resolve yer weak self issue.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)