? Septembre 2014 Novembre 2014 Juin 2014 Apple annonce Swift Swift 1.0 " Première application Swift Xebia sur l’App Store ? Février 2015 Nouvelles applications ?
? Juin 2014 Apple annonce Swift Septembre 2014 Swift 1.0 Novembre 2014 " Première application Swift Xebia sur l’App Store ? Février 2015 Nouvelles applications !
? Octobre 2014 Swift 1.1 September 2015 Swift 2.0 Octobre 2014 Swift 2.1 April 2015 Swift 1.2 Juin 2014 Apple annonce Swift Septembre 2014 Swift 1.0 Novembre 2014 " Première application Swift Xebia sur l’App Store ? Février 2015 Nouvelles applications ! Mars 2016 Swift 2.2
d’usage Flux d’activité Création du projet et configuration Produits et synchronisation Langues Commentaires Testing Suivre son application Et l’Objective-C ?
Attachment { let id: Int let url: String let type: String let name: String let objectId: Int let mimeType: String let objectType: String } Flux d’activités Exemple de Struct
Generics class EntityStore<T: Entity> { func addEntity(entity: T) { // Some implementation } } ... func addSomeObjects() { let productStore = EntityStore<Product>() // Product conforms to Entity let product = Product() productStore.addEntity(product) // Color conforms to Entity let color = Color() productStore.addEntity(color) } func addSomeObjects() { let productStore = EntityStore<Product>() // Product conforms to Entity let product = Product() productStore.addEntity(product) // Color conforms to Entity let color = Color() productStore.addEntity(color) } Un peu de Swift
{ static func load(id: String) -> Self? } class Product : Loadable { static func load(id: String) -> Self? { // Open the default database store // Look for the id // etc } } Liste de produits
Protocols protocol Loadable { static func load(id: String) -> Self? } class Color : Loadable { static func load(id: String) -> Self? { // Open the default database store // Look for the id // etc } }
Reactive Programming ^{ available in guard let available = available as? Bool else { return } availabilitySpinner.stopAnimating() availabilityIndicator.textColor = colorForStatus(available) } <~ KVO.stream(viewModel, "status")
let availabilitySignal = KVO.signal(viewModel, "status") .map { status -> String? in return status as? String } .map { status -> Bool in return status == "available" } .delay(1.0) Disponibilité produit
Custom ^{ available in guard let available = available as? Bool else { return } availabilitySpinner.stopAnimating() availabilityIndicator.textColor = colorForStatus(available) } <~ KVO.stream(viewModel, "status") <~
Country { case USA case China case Italy static var preferred: Country { return Country.Italy } } Country.preferred // .Italy Et finalement du Swift Valeurs associées
Country: String { case USA case Italy var name: String { switch self { case USA: return "United States" case Italy: return "Italia!" } } } Country.Italy.name // .Italia! Et finalement du Swift Propriétés
Language { case English(country: Country) case Italian var language: String { switch self { case .English(let country): return "English \(country.name)" // ... } } Language.English(country: .USA).name // English (United States) Swift Value binding
Swift VS Swift class Store { func addEntity(entity: Product) { // Some implementation } } let entityStore = EntityStore() let product = Product() entityStore.addEntity(product) Coder Swift != Penser Swift class Store<T: Entity> { func addEntity(entity: T) { // Some implementation } } let productStore = ProductStore() let product = Product() product.save(productStore) Generics Typealias Protocol extensions
lecture A Swift Kickstart Daniel Steinberg Functional Programming in Swift Chris Eidhof, Florian Kugler, and Wouter Swierstra http://blog.xebia.fr/tag/swift L’équipe iOS Xebia Advanced Swift Chris Eidhof and Airspeed Velocity