Upload
tlv-ios-dev
View
96
Download
1
Tags:
Embed Size (px)
Citation preview
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
GoalsUnderstand Swift betterThe challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
Why fear Swift?People fear change
Forget everything you believe in
It just (doesn’t) workCan’t teach old dog new tricks
Everyone is already doing it
Why should I start writing code in Swift?
* Because Apple said so* Swift is cool* Swift has a lot of benefits* Now easier with Swift 2.0
Excuses
* ObjC still works* Swift will probably change a million more times.* Can’t release a Swift 2.0 app until iOS 9.* I like my []
GoalsUnderstand Swift betterThe challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
GoalsUnderstand Swift better
The challenges we faced at Houzz8 features of Swift
(good bad and ugly)
Beginner’s guide
Today view controller:
Table view cell
The app.
Share extension:
Mostly SwiftComplex logic.
Cool stuff
Today view controller:
Table view cell
The app.
Share extension:
Mostly SwiftComplex logic.
Pyramid of doom
Today view controller:
Table view cell
The app.
Share extension:
Mostly SwiftComplex logic.
Cool switchcases
Today view controller:
Table view cell
The app.
Share extension:
Mostly SwiftComplex logic.
Hard times:
The app.Code structure
~1300 objective c classes~100 Swift classes
Tons of customization
Tons of swizzling and class injection
(auto resizing table views, custom constraints, graphic effect, HTML text labels, auto serializing objects etc..
etc.. etc..
(Auto releasing blocked base KVO, iOS 7 based collection traits and user activities…)
Localized to 15 languages.Some code dates back to 2009
GoalsUnderstand Swift better
The challenges we faced at Houzz8 features of Swift
(good bad and ugly)
Beginner’s guide
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
1. Variable willSet and didSet and lazyAwesome replacement for custom getters and setters or internal KVO
Makes Swift safer
Great trick for thinning viewDidLoad(nice side effect - helps avoid nil outlets)not called during init / deinit
GOOD:
BAD:
no built in replacement for atomic.UGLY:
8 features of Swift
2. Optionals8 features of Swift
Optionals express nullability(no difference between primitives and objects)
2. Optionals
Great way to express nullabilityAwesome for searches.
You need to get the hang of it.
GOOD:
BAD: Welcome to a new world of runtime errors.
UGLY:Don’t just add ! or ? or ?! and wait for it to compile
8 features of Swift
3. Slow or fast?
Great way to get reacquainted with your Facebook friends.
Getting the error message at the end of the compilation
GOOD:
BAD: Debug code can fool you.
UGLY:
Runtime code can be fastMake sure you test in release modeMake sure you play nice; final, let/var, privates, minimize bridging, bitcode, whole module optimization etc…
8 features of Swift
5. Structs and protocols8 features of Swift
New building blocks of Swift code.
No (or limited) ObjC support
GOOD:
BAD: Can be confusing when to use a class and when to use a struct
UGLY:
Can do almost anything a class doesValue semanticsCan be put directly in any collection typeProtocol Oriented Programming
7. Type accuracy
Safer code
Can be cumbersome
GOOD:
BAD:Error messages.UGLY:
Much better with Swift 2.0
8 features of Swift
8. @availableIn Houzz we swizzle and inject a lot
Swift 2.0 availability forbids itrespondsToSelector is not safe
Workaround - put in the bridging header
8 features of Swift
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
Where do I start ?WWDC 2014* Beginner Swift* Intermediate Swift* Swift - ObjC interoperabilityThen go and write some Swift codeWWDC 2015* What’s new in Swift* Protocol oriented programming in SwiftThen go and write some Swift code
Beginner’s guide
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide
GoalsUnderstand Swift better
The challenges we faced at Houzz
8 features of Swift(good bad and ugly)
Beginner’s guide