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
// A とそのサブクラス B が、"プロパティnameを持つ" SomeProtocolに準拠することを宣言。 | |
class A {} | |
class B: A {} | |
protocol SomeProtocol { var whatYourName: Void { get } } | |
extension A: SomeProtocol {} | |
// Aにnameのデフォルト実装を用意 | |
extension SomeProtocol where Self: A { | |
var whatYourName: Void { print("My name is A") } | |
} | |
// BはAを継承していますが、更にデフォルト実装を上書きします |
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
protocol SomeProtocol { | |
var name: String { get } | |
} | |
class A {} | |
class B: A {} | |
extension A: SomeProtocol {} | |
extension SomeProtocol where Self: A { | |
var name: String { return "My name is A" } | |
} |
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
protocol SomeProtocol { | |
var name: String { get } | |
} | |
class A {} | |
class B: A {} | |
extension A: SomeProtocol {} | |
extension SomeProtocol where Self: A { | |
var name: String { return "My name is A" } | |
} |
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
class hoge { | |
var currentIndex: Int = NSNotFound | |
} |
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
var statusCode = 200 | |
if 400..<500 ~= statusCode { | |
print("400台ダヨ") | |
} else { | |
print("知らないヨ") | |
} |
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
var statusCode = 200 | |
switch statusCode { | |
case 400..<500 : | |
print("400台ダヨ") | |
default: | |
print("知らないヨ") | |
} |
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
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{ | |
if (error && !([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) { | |
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Error : %ld",(long)error.code] | |
message:error.localizedDescription | |
preferredStyle:UIAlertControllerStyleAlert]; | |
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" | |
style:UIAlertActionStyleCancel | |
handler:nil]]; | |
// 続けるボタン |
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
NSLog(@"%d:%d:%d",(error.domain == NSURLErrorDomain), [error.domain isEqual:NSURLErrorDomain], [error.domain isEqualToString:NSURLErrorDomain] ); | |
// 0:1:1 |
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
NSLog(@"Hello!"); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |