Swift - Assign a NIB to self in class
问题 I am creating a UIView subclass for a notification dropdown banner. I am using a XIB to build out the view and want to assign that xib to the class when it initializes (i.e. avoiding having to do this from the calling ViewController). Since you can't assign to 'self' in swift, how do I properly do this from within the class itself? class MyDropDown: UIView { func showNotification() { self = UINib(nibName: nibNamed, bundle: bundle).instantiateWithOwner(nil, options: nil)[0] as? UIView } } 回答1: