Submit Search
Upload
Develop with Swift
•
4 likes
•
1,266 views
Naoki Morita
Follow
The environment of Swift development is already prepared!
Read less
Read more
Technology
Report
Share
Report
Share
1 of 39
Download now
Download to read offline
Recommended
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
Esther Lozano
Angular testing
Angular testing
Yu Jin
Javascript unit tests with angular 1.x
Javascript unit tests with angular 1.x
Ron Apelbaum
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
Intro to node.js web apps
Intro to node.js web apps
Thanos Polychronakis
Entities on Node.JS
Entities on Node.JS
Thanos Polychronakis
The Ruby Racer: under the hood
The Ruby Racer: under the hood
cowboyd
Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015
Jorge Franco Leza
Recommended
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
Esther Lozano
Angular testing
Angular testing
Yu Jin
Javascript unit tests with angular 1.x
Javascript unit tests with angular 1.x
Ron Apelbaum
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
Intro to node.js web apps
Intro to node.js web apps
Thanos Polychronakis
Entities on Node.JS
Entities on Node.JS
Thanos Polychronakis
The Ruby Racer: under the hood
The Ruby Racer: under the hood
cowboyd
Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015
Jorge Franco Leza
Back to the future: Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
Luciano Colosio
How to add Fixtures into your Django app with Mixer
How to add Fixtures into your Django app with Mixer
Guinsly Mondesir
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
QAware GmbH
Grooscript greach
Grooscript greach
Jorge Franco Leza
Grooscript gr8conf 2015
Grooscript gr8conf 2015
Jorge Franco Leza
Server Side Swift
Server Side Swift
Jens Ravens
Grooscript greach 2015
Grooscript greach 2015
Jorge Franco Leza
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
James Williams
Sima Vasa - Cutting Edge of NewMR 2015
Sima Vasa - Cutting Edge of NewMR 2015
Ray Poynter
My toolbox (materials, shapes and Tools)
My toolbox (materials, shapes and Tools)
Anna Capdevila
Siphokuhle Mahonga cv false bay
Siphokuhle Mahonga cv false bay
sipphokuhle mahonga
WOW pro file 2
WOW pro file 2
WOWCOIN
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Chris Parry
Realm - Phoenix Mobile Festival
Realm - Phoenix Mobile Festival
DJ Rausch
Grand Union Digital Index - Brand internazionali della cosmetica
Grand Union Digital Index - Brand internazionali della cosmetica
Grand Union Italia
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015
Tung Nguyen Thanh
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous Integration
Tung Nguyen Thanh
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSockets
Ben Limmer
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
Rod King, Ph.D.
Пожежна безпека
Пожежна безпека
Ольга Радіонова
Crear formulario windows form con visual c++ 2015
Crear formulario windows form con visual c++ 2015
Ángel Acaymo M. G.
«10 лет измерений. эволюция или революция»
«10 лет измерений. эволюция или революция»
PR News
More Related Content
What's hot
Back to the future: Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
Luciano Colosio
How to add Fixtures into your Django app with Mixer
How to add Fixtures into your Django app with Mixer
Guinsly Mondesir
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
QAware GmbH
Grooscript greach
Grooscript greach
Jorge Franco Leza
Grooscript gr8conf 2015
Grooscript gr8conf 2015
Jorge Franco Leza
Server Side Swift
Server Side Swift
Jens Ravens
Grooscript greach 2015
Grooscript greach 2015
Jorge Franco Leza
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
James Williams
What's hot
(8)
Back to the future: Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
How to add Fixtures into your Django app with Mixer
How to add Fixtures into your Django app with Mixer
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Grooscript greach
Grooscript greach
Grooscript gr8conf 2015
Grooscript gr8conf 2015
Server Side Swift
Server Side Swift
Grooscript greach 2015
Grooscript greach 2015
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
Viewers also liked
Sima Vasa - Cutting Edge of NewMR 2015
Sima Vasa - Cutting Edge of NewMR 2015
Ray Poynter
My toolbox (materials, shapes and Tools)
My toolbox (materials, shapes and Tools)
Anna Capdevila
Siphokuhle Mahonga cv false bay
Siphokuhle Mahonga cv false bay
sipphokuhle mahonga
WOW pro file 2
WOW pro file 2
WOWCOIN
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Chris Parry
Realm - Phoenix Mobile Festival
Realm - Phoenix Mobile Festival
DJ Rausch
Grand Union Digital Index - Brand internazionali della cosmetica
Grand Union Digital Index - Brand internazionali della cosmetica
Grand Union Italia
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015
Tung Nguyen Thanh
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous Integration
Tung Nguyen Thanh
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSockets
Ben Limmer
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
Rod King, Ph.D.
Пожежна безпека
Пожежна безпека
Ольга Радіонова
Crear formulario windows form con visual c++ 2015
Crear formulario windows form con visual c++ 2015
Ángel Acaymo M. G.
«10 лет измерений. эволюция или революция»
«10 лет измерений. эволюция или революция»
PR News
Onderweg naar Accountant3.0
Onderweg naar Accountant3.0
drs Pieter de Kok RA
Software y energía cpc
Software y energía cpc
andrea_135
Dojo Grids in XPages
Dojo Grids in XPages
Teamstudio
Aect480 lecture 7
Aect480 lecture 7
cloudc123
Importanos 2016. Cidadania e participación contra a pobreza 151216 Xosé Cuns
Importanos 2016. Cidadania e participación contra a pobreza 151216 Xosé Cuns
Xose Cuns Traba
Selections womens wovens aw 2014
Selections womens wovens aw 2014
TFCExpress
Viewers also liked
(20)
Sima Vasa - Cutting Edge of NewMR 2015
Sima Vasa - Cutting Edge of NewMR 2015
My toolbox (materials, shapes and Tools)
My toolbox (materials, shapes and Tools)
Siphokuhle Mahonga cv false bay
Siphokuhle Mahonga cv false bay
WOW pro file 2
WOW pro file 2
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Parry_2011_Exploration_Revived_Bergen_Opening_of_the_ North_ Atlantic_Basin_L...
Realm - Phoenix Mobile Festival
Realm - Phoenix Mobile Festival
Grand Union Digital Index - Brand internazionali della cosmetica
Grand Union Digital Index - Brand internazionali della cosmetica
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous Integration
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSockets
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
BCG-Business Model Strip: A Visual Tool for Continuously Improving and Innova...
Пожежна безпека
Пожежна безпека
Crear formulario windows form con visual c++ 2015
Crear formulario windows form con visual c++ 2015
«10 лет измерений. эволюция или революция»
«10 лет измерений. эволюция или революция»
Onderweg naar Accountant3.0
Onderweg naar Accountant3.0
Software y energía cpc
Software y energía cpc
Dojo Grids in XPages
Dojo Grids in XPages
Aect480 lecture 7
Aect480 lecture 7
Importanos 2016. Cidadania e participación contra a pobreza 151216 Xosé Cuns
Importanos 2016. Cidadania e participación contra a pobreza 151216 Xosé Cuns
Selections womens wovens aw 2014
Selections womens wovens aw 2014
Similar to Develop with Swift
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Java User Group Latvia
Go react codelab
Go react codelab
Alberto Jesús Gutiérrez Juanes
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Matteo Collina
Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwan
modernweb
Adopting F# at SBTech
Adopting F# at SBTech
Antya Dev
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
All a flutter about Flutter.io
All a flutter about Flutter.io
Steven Cooper
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
Luciano Mammino
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
Núcleo de Electrónica e Informática da Universidade do Algarve
Reactive, component 그리고 angular2
Reactive, component 그리고 angular2
Jeado Ko
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
Swift and Kotlin Presentation
Swift and Kotlin Presentation
Andrzej Sitek
Getting Started With Kotlin Development - Rivu
Getting Started With Kotlin Development - Rivu
CodeOps Technologies LLP
NodeJS
NodeJS
Alok Guha
Advanced Javascript Unit Testing
Advanced Javascript Unit Testing
Lars Thorup
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
César Hernández
Everything-as-code. A polyglot journey.
Everything-as-code. A polyglot journey.
Mario-Leander Reimer
Everything-as-code - a polyglot journey.
Everything-as-code - a polyglot journey.
QAware GmbH
GWT Extreme!
GWT Extreme!
cromwellian
Android architecture component - FbCircleDev Yogyakarta Indonesia
Android architecture component - FbCircleDev Yogyakarta Indonesia
Pratama Nur Wijaya
Similar to Develop with Swift
(20)
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Go react codelab
Go react codelab
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwan
Adopting F# at SBTech
Adopting F# at SBTech
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
All a flutter about Flutter.io
All a flutter about Flutter.io
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
Reactive, component 그리고 angular2
Reactive, component 그리고 angular2
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
Swift and Kotlin Presentation
Swift and Kotlin Presentation
Getting Started With Kotlin Development - Rivu
Getting Started With Kotlin Development - Rivu
NodeJS
NodeJS
Advanced Javascript Unit Testing
Advanced Javascript Unit Testing
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
Everything-as-code. A polyglot journey.
Everything-as-code. A polyglot journey.
Everything-as-code - a polyglot journey.
Everything-as-code - a polyglot journey.
GWT Extreme!
GWT Extreme!
Android architecture component - FbCircleDev Yogyakarta Indonesia
Android architecture component - FbCircleDev Yogyakarta Indonesia
Recently uploaded
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Michael W. Hawkins
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Katpro Technologies
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Antenna Manufacturer Coco
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Khem
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Rafal Los
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Results
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Neo4j
Recently uploaded
(20)
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Develop with Swift
1.
Develop with Swift
2.
森田 直樹
3.
morizotter
4.
2015
5.
Github http://github.com/morizotter
6.
Github Award https://github-awards.com/users/search?login=morizotter
7.
TouchVisualizer https://github.com/morizotter/TouchVisualizer
8.
SwiftyDrop https://github.com/morizotter/SwiftyDrop
9.
Coggle https://coggle.it
10.
Coggle https://coggle.it
11.
Coggle https://coggle.it
12.
Coggle https://coggle.it
13.
angularjs-style-guide https://github.com/mgechev/angularjs-style-guide/blob/ master/README-ja-jp.md
14.
angularjs-style-guide https://github.com/mgechev/angularjs-style-guide/blob/ master/README-ja-jp.md
15.
Other contributions • SDWebImage •
SwiftBond - Japanese 2 way binding • Evernote SDK • Treasuredata SDK • DateTools • Carthage • NVActivityIndicatorView • TagListView • FlatUIColors • …
16.
Develop with Swift
17.
Qolk Cozy Qiita Reader
for iOS.
18.
Qolk Cozy Qiita Reader
for iOS.
19.
Qolk QiitaクライアントのQolkをMacbookとCarthageで作った話 http://qiita.com/morizotter/items/90d6d6024a6e7e0e9e84
20.
Powerful Swift OSSs. •
Dependency Manager: Carthage • Networking: Alamofire • JSON parser: SwiftyJSON • Database: Realm • Future(promise): BrightFutures • View binding: SwiftBond • Image loading: Kingfisher • AutoLayout: SnapKit
21.
Powerful Swift OSSs. •
Dependency Manager: Carthage Cocoapods • Networking: Alamofire AFNetworking • JSON parser: SwiftyJSON Mantle • Database: Realm MagicalRecord/CoreData • Future(promise): BrightFutures Bolts/PromiseKit • View binding: SwiftBond ReactiveCocoa? • Image loading: Kingfisher SDWebImage • AutoLayout: SnapKit Masonry Objective-C?
22.
Core OSSs • Carthage •
Alamofire • BrightFutures • SwiftyJSON
23.
Carthage for all
24.
Carthage • Decentralized • No
.xcworkspace • Clean & Simple • Very Easy to distribute • Increasing • Centralized • .xcworkspace • Easy to use • Easy to distribute • Already many Cocoapods https://github.com/Carthage/Carthage https://cocoapods.org/
25.
Carthage $ brew update $
brew install carthage $ cd move/to/app/root $ vi Cartfile github "Alamofire/Alamofire" == 3.1.2 wq $ carthage update -platform ios
26.
Carthage
27.
Carthage • Pros: • Project
remains clean. • No build time. • Cons: • Library build time. • Relatively fewer libraries.
28.
If library doesn’t compatible
with Carthage?
29.
Fork! Tweak! (Pull Request!)
30.
Just 4 steps 1.
Create CocoaTouch Framework 2. Add files to Framework target 3. Make scheme shared 4. git push and tag in Github
31.
I made 5
libraries or more Carthage Compatible for Qolk.
32.
Many Thanks.
33.
Alamofire SwiftyJSON BrightFutures cooperate.
34.
BrightFutures Networking system API Server App SwiftyJSON
35.
Alamofire & BrightFutures //
AlamofireClient.swift struct AlamofireClient { static let sharedInstance = AlamofireClient() let alamofire: Manager init() { let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.timeoutIntervalForResource = RequestTimeoutSec alamofire = Manager(configuration: configuration) } static func requestJSON(URLRequest: URLRequestConvertible) -> Future<JSONResponse, ErrorResponse> { let promise = Promise<JSONResponse, ErrorResponse>() sharedInstance.alamofire.request(URLRequest) .validate() .responseJSON(options: .AllowFragments) { (response) -> Void in log.debug("REQUEST: (response.request)") log.debug("RESPONSE: (response.response)”) switch response.result { case .Success(let json): log.debug("[QIITA] JSON: (json)") promise.success(JSONResponse(json: json, response: response.response!)) case .Failure(let error): log.debug("[QIITA] ERROR: (error.localizedDescription)") self.errorHandling(error, response: response.response) promise.failure(ErrorResponse(nsError: error, response: response.response)) } } return promise.future } … } Return future.
36.
Responses // AlamofireClient.swift struct JSONResponse
{ var json = JSON([]) var response: NSHTTPURLResponse? var rateLimit: Int? var rateRemaining: Int? init(json: AnyObject?, response: NSHTTPURLResponse?) { if let json = json { self.json = JSON(json) } if let response = response { self.response = response let headers = JSON(response.allHeaderFields) self.rateLimit = headers["Rate-Limit"].int self.rateRemaining = headers["Rate-Remaining"].int } } } struct ErrorResponse: ErrorType { var error: NSError var response: NSHTTPURLResponse? init(error: NSError, response: NSHTTPURLResponse? = nil) { self.nsError = error self.response = response } } Make original struct for easy handling.
37.
BrightFutures & SwiftyJSON //
AppManager.swift func getItems(pageInfo: PageInfo, query: String?) -> PageResponseFuture { let promise = Promise<PageResponse, ErrorResponse>() AlamofireClient.requestJSON(QiitaAPIRouter.Items(pageInfo: pageInfo, query: query)) .onSuccess { (result: JSONResponse) in let pageResponse = PageResponse(json: result.json, pageInfo: pageInfo, response: result.response!) promise.success(pageResponse) } .onFailure { (errorResponse: ErrorResponse) in promise.failure(errorResponse) } return promise.future } struct PageResponse { var json: JSON var totalCount: Int? var pageInfo: PageInfo init(json: JSON, pageInfo: PageInfo, response: NSHTTPURLResponse?) { self.json = json self.pageInfo = pageInfo if let response = response { let headers = JSON(response.allHeaderFields) self.totalCount = headers["Total-Count"].intValue } } } typealias PageResponseFuture = Future<PageResponse, ErrorResponse> Inject something before network returns.
38.
SwiftyJSON final class Item:
Object, ObjectCopyable { dynamic var renderedBody = "" dynamic var body = "" dynamic var coediting = false dynamic var createdAt = "" dynamic var itemId = "" dynamic var isPrivate = false let tags = List<Tag>() dynamic var title = "" dynamic var updatedAt = "" dynamic var url = "" dynamic var user: User? override static func primaryKey() -> String? { return "itemId" } class func fromJSON(json: JSON) -> Item { let item = Item() item.renderedBody = json["rendered_body"].stringValue item.body = json["body"].stringValue item.coediting = json["coediting"].boolValue item.createdAt = json["created_at"].stringValue item.itemId = json["id"].stringValue item.isPrivate = json["private"].boolValue item.title = json["title"].stringValue item.updatedAt = json["updated_at"].stringValue item.url = json["url"].stringValue item.user = User.fromJSON(json["user"]) for (_, subJson): (String, JSON) in json["tags"] { item.tags.append(Tag.fromJSON(subJson)) } return item } … }
39.
Sync Wantedly
Download now