Swift
-
Upload
quentin-de-quelen -
Category
Mobile
-
view
36 -
download
6
Transcript of Swift
Différence avec l’Objective-c
NSArray *unsortedArray = @[@"Ahmed", @"Marwa", @"Siva", @"Paul", @"Otto", @"Sam", @"Candy"]; NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:NO selector:@selector(localizedCompare:)]; NSArray* sortedArray = [unsortedArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; //SortedArray = [Siva, Sam, Paul, Otto, Marwa, Candy, Ahmed]
Différence avec l’Objective-c
let names = ["Ahmed", "Marwa", "Siva", "Paul", "Otto", "Sam", "Candy"] reversed = sort(names, {>}) // reversed = [Siva, Sam, Paul, Otto, Marwa, Candy, Ahmed]
Swift + Objective-C
#ifndef RandomailApp_Bridging_Header_h #define RandomailApp_Bridging_Header_h
#import <UIKit/UIKit.h> #import "DTCoreText.h"
#endif
Cocoapods : exemple
platform :ios, '8.0'
pod 'Alamofire' pod 'MaterialKit' pod 'Toucan' pod 'SwiftyJSON' pod 'SwiftyUserDefaults' pod 'KeychainSwift' pod 'JLToast' pod 'Spring' pod 'GoogleAnalytics-iOS-SDK', '~> 3.10'
Cocoapods : exemple
platform :ios, '8.0'
pod 'Alamofire' pod 'MaterialKit' pod 'Toucan' pod 'SwiftyJSON' pod 'SwiftyUserDefaults' pod 'KeychainSwift' pod 'JLToast' pod 'Spring' pod 'GoogleAnalytics-iOS-SDK', '~> 3.10'
Cocoapods : exempleuse_frameworks!
platform :ios, '8.0'
pod 'Alamofire' pod 'MaterialKit' pod 'Toucan' pod 'SwiftyJSON' pod 'SwiftyUserDefaults' pod 'KeychainSwift' pod 'JLToast' pod 'Spring' pod 'GoogleAnalytics-iOS-SDK', '~> 3.10'
// Fetch Request Alamofire.request(.POST, urlString, parameters: bodyParameters, encoding: encoding) .validate(statusCode: 200..<300) .responseJSON{(request, response, JSON, error) in println("HTTP Response Body: \(JSON)") if (error == nil) { println("HTTP Response Body: \(JSON)") successful(true) } else { successful(false) println("HTTP HTTP Request failed: \(error)") } }
Alamofire
SwiftyJSON - Avantlet jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(dataFromTwitter, options: NSJSONReadingOptions.MutableContainers, error: nil) if let statusesArray = jsonObject as? NSArray{ if let aStatus = statusesArray[0] as? NSDictionary{ if let user = aStatus["user"] as? NSDictionary{ if let userName = user["name"] as? NSDictionary{ //Finally We Got The Name } } } }
SwiftyJSON - Avantlet jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(dataFromTwitter, options: NSJSONReadingOptions.MutableContainers, error: nil) if let statusesArray = jsonObject as? NSArray{ if let aStatus = statusesArray[0] as? NSDictionary{ if let user = aStatus["user"] as? NSDictionary{ if let userName = user["name"] as? NSDictionary{ //Finally We Got The Name } } } }
SwiftyJSON - Après
let json = JSON(data: dataFromNetworking) if let userName = json[0]["user"]["name"].string{ //Now you got your value }
ResearchKit
Kit de développement
Recherche médicale
Lié à HealthKit
Données centralisées
Open source
HomeKit
Kit de développement
Connexion à un objet connecté
Lie des action aux objets
Normalisation des communications
Normalisation des actions
Kit de développement
import SceneKit import SpriteKit import HealthKit import ResearchKit import HomeKit import WatchKit import UIKit import Foundation
Plus d’information
Swift Language Documentation
http://developer.apple.com/swift
Apple Developer Forums
http://developer.apple.com/forums
Quentin de Quelen
Swift Evangelist