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
| import Foundation | |
| protocol Observer { | |
| var id: String { get } | |
| func update(_ string: String) | |
| } | |
| extension Observer { | |
| func update(_ string: String) { | |
| print("\(type(of: self)) に届いた新しい値は \(string) です。") |
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
| import Foundation | |
| protocol Observer { | |
| var id: String { get } | |
| func update(_ string: String) | |
| } | |
| extension Observer { | |
| func update(_ string: String) { | |
| print("\(type(of: self)) に届いた新しい値は \(string) です。") |
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
| // | |
| // RW.swift | |
| // Web | |
| // | |
| // Created by Mike Chirico on 10/15/15. | |
| // Copyright © 2015 Mike Chirico. All rights reserved. | |
| // | |
| import UIKit |
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
| let firstTodoEndpoint: String = "http://jsonplaceholder.typicode.com/todos/1" | |
| let firstTodoUrlRequest = NSMutableURLRequest(URL: NSURL(string: firstTodoEndpoint)!) firstTodoUrlRequest.HTTPMethod = "DELETE" | |
| let session = NSURLSession.sharedSession() | |
| let task = session.dataTaskWithRequest(firstTodoUrlRequest) { (data, response, error) in | |
| guard let _ = data else { | |
| print("error calling DELETE on /todos/1") | |
| return | |
| } | |
| print("DELETE ok") |
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
| func printData(){ | |
| guard let path = NSBundle.mainBundle().pathForResource("contacts", ofType: "txt") else { | |
| print("Error while reading data") | |
| return | |
| } | |
| do { | |
| let content = try String(contentsOfFile: path, encoding: NSUTF8StringEncoding) | |
| print(content) |
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
| func printData(){ | |
| guard let path = NSBundle.mainBundle().pathForResource("contacts", ofType: "txt") else { | |
| print("Error while reading data") | |
| return | |
| } | |
| do { | |
| let content = try String(contentsOfFile: path, encoding: NSUTF8StringEncoding) | |
| print(content) |
NewerOlder