Created
November 8, 2015 14:33
-
-
Save YusukeHosonuma/9dc1f19bb9149d50243a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// APISample | |
// | |
// Created by Yusuke on 11/8/15. | |
// Copyright © 2015 Yusuke. All rights reserved. | |
// | |
import UIKit | |
class ViewController: UIViewController, NSURLSessionDelegate { | |
var api = SampleAPI() | |
func handleAPI(apiResult: SampleAPI.APIResult) { | |
switch apiResult { | |
case .Success(let result): | |
print(result) | |
case .Error: | |
print("Error") | |
} | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
api.getTaskList(true, handler: handleAPI) | |
api.getTaskList(false, handler: handleAPI) | |
// // セッション作成 | |
// let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration() | |
// | |
// // タイムアウトの設定 | |
// sessionConfig.timeoutIntervalForRequest = 10; | |
// sessionConfig.timeoutIntervalForResource = 20; | |
// | |
// let sessionConnect = NSURLSession(configuration: sessionConfig, | |
// delegate: self, | |
// delegateQueue: NSOperationQueue.mainQueue()) | |
// | |
// let request = NSURLRequest(URL: NSURL(string: "https://localhost:3000/")!) | |
// let data = sessionConnect.dataTaskWithRequest(request) { (data, response, error) -> Void in | |
// let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding) | |
// print(responseString) | |
// } | |
// data.resume() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment