This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Json is always contained between curly braces: | |
| { | |
| "Text here" | |
| } | |
| Inside the curly braces you can have a "list" or array, this list has a string, a number, and a boolean. Note that the elements of a lost are separated by commas: | |
| { | |
| "Text here", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let tapClosure: (UITapGestureRecognizer) -> () = { (tapRecognizer) in | |
| print("In tap closure") | |
| } | |
| let recognizer = ClosureGestureRecognizer(action: tapClosure) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClosureGestureRecognizer<GestureRecognizer: UIGestureRecognizer> { | |
| fileprivate var recognizer: GestureRecognizer | |
| private var actionHandler: ((GestureRecognizer) -> Void) | |
| init(action: @escaping (GestureRecognizer) -> ()) { | |
| self.recognizer = GestureRecognizer() | |
| self.actionHandler = action | |
| self.recognizer.addTarget(self, action: #selector(handleAction)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HelloViewController: UIViewController { | |
| let label = UILabel(frame: .zero) | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| label.text = "Hello world!" | |
| label.translatesAutoresizingMaskIntoConstraints = false | |
| label.font = UIFont.systemFont(ofSize: 16.0, weight: .medium) | |
| label.textColor = .black | |
| label.textAlignment = .center |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let attributes = [ NSForegroundColorAttributeName : self.view.tintColor ] | |
| let attributedString = NSAttributedString(string: NSLocalizedString("Sign In", comment: ""), attributes: attributes) | |
| warns: (Expression implicitly coerced from 'UIColor?' to Any) | |
| right way: | |
| let attributes: [ String : UIColor ] | |
| if let maybeAttributes = [ NSForegroundColorAttributeName : self.view.tintColor ] { | |
| attributes = maybeAttributes | |
| } else { | |
| assertionFailure("self.view.tintColor is nil") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SuperClass { | |
| var aBool : Bool = false { | |
| didSet { | |
| print(aBool) | |
| } | |
| } | |
| } |