Reid's Notes on Swift ===================== Hey Cool! --------- * you can directly manipulate CGRects. No more assigning to a "Frame" variable and assigning back to the view.frame: self.frame.size.height += 44 // woo! Things to get used to --------------------- * Implicit typing works. Learn to leave out the type of a variable as it can usually be inferred from the return type of the assignment: let foo = self.method() * don't forget the "override" prefix when you override a method -- you'll get a compiler error, but I'm mentioning it anyway :-) * all Swift code knows about all other Swift code; it's like everyone #imports everyone else * enums are much more powerful than in any other language; I'm still getting used to them. e.g.: ``` enum KnownVertical : String { case Movie = "movies" case Restaurant = "restaurants" case Place = "bars & clubs" case Location = "people" case Person = "person" case Gas = "gas" case Events = "events" case YouTube = "youtube" case Parking = "parking" } ``` * properties have post- and pre-setting "methods", which can be handy ``` var foo: String { willSet { ... } set { ... } didSet { ... } } ``` Huh, that's not obvious ----------------------- * To use Swift classes in Objective-C, you have to #import a generated header file that is NOT very well documented. It's called `"<target>-Swift.h"`; e.g. `"Poynt-Swift.h"` * You don't need the `@objc` prefix on classes that inherit from Objective-C classes. Weird! ------ * `dealloc()` is "unavailable" use a special `deinit` instead. It's not a func or anything. Just plain `deinit { .. }` * You can't use the `recursiveDescription` debugging method on `UIView` unless you add this to the bridging header (no implementation necessary) ``` @interface UIView (Debug) - (id)recursiveDescription; - (id)_autolayoutTrace; @end ``` Not sure what `_autolayoutTrace` does, but someone said it was sweet.