This intends to be copy pasted in an iOS Xcode project to facilitate things we do all the time :)
Observe
NotificationCenter.default.addObserver(self, selector: #selector(someFunction), name: NSNotification.Name(rawValue:"MyNotification"),object: nil)observe("MyNotification", #selector(someFunction))Post
NotificationCenter.default.post(name: NSNotification.Name(rawValue:"MyNotif"), object: nil, userInfo: nil)notify("MyNotif")button.addTarget(self, action: #selector(someFunction), for: .touchUpInside)bindTap(of: button, #selector(someFunction))NSLocalizedString("TranslationKey", comment: "")localized("TranslationKey")UIColor(red: 100 / 255.0, green: 224 / 255.0, blue: 132 / 255.0, alpha: 1)UIColor(R: 100, G: 224, B: 132)navigationController?.pushViewController(vc, animated: true)push(vc)presentViewController(vc, animated: true, completion: nil)present(vc)navigationController?.popViewControllerAnimated(true)pop()dismissViewControllerAnimated(true, completion: nil)dismiss()if let t = textfield.text where !t.isEmpty {
print("not empty")
}if textfield.hasContent {
print("not empty")
}if let v = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
let keyboardHeight = v.CGRectValue().size.height
}notification.keyboardHeightbutton.setBackgroundColor(.blueColor(), forState: .Normal)