web: gil.sh github: shilgapira
Quick intro
Swift
Demo
Data
Presentation
Behavior
Entities
Persistence
Network
struct User {
// 10374498
let id: Int64
// "John"
let firstName: String
// "Appleseed"
let lastName: String
// From unix timestamp perhaps
let birthday: NSDate?
// URL of an image
let pictureURL: String?
// Coordinates of user's home
let home: CLLocation?
}
Value Transformations
View State
Input Validation
Operations and Actions
class UserViewModel {
// "John A."
var name: String
// "In 12 days", "In August", "Unknown"
var birthday: String
// "8 miles away", "New York", "Unknown"
var distanceToHome: String
// .Network provides a URL for a remote image,
// .Placeholder provides initials of user's name and background fill color
var picture: Picture
enum Picture {
case Network(NSURL)
case Placeholder(String, UInt64)
}
// ... implementation ...
}
User Interface
Data Updates
Events
Separation of Concerns
Unit Testing
Code Reuse
iOS / OS X