This file contains 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
override public func viewDidLoad() { | |
super.viewDidLoad() | |
print("Hello world") | |
} |
This file contains 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 World!"); | |
float aFloat = 1.2345; | |
NSLog(@"This is a float: %f", aFloat); |
This file contains 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
switch responseCode { | |
case -1: | |
text = "Unknown error" | |
break | |
case 0: | |
text = "Code is accepted" | |
break | |
} |
This file contains 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 alert = UIAlertController(title: "Simple Title", | |
message: "Alert message", | |
preferredStyle: .alert) | |
let okAction = UIAlertAction(title: "Close", style: .default) | |
alert.addAction(okAction) | |
DispatchQueue.main.async { | |
UIApplication.topViewController()?.present(alert, animated: true, completion: nil) | |
} |
This file contains 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
self.demoView.translatesAutoresizingMaskIntoConstraints = NO; | |
UILayoutGuide * guide = self.view.safeAreaLayoutGuide; | |
[self.demoView.leadingAnchor constraintEqualToAnchor:guide.leadingAnchor].active = YES; | |
[self.demoView.trailingAnchor constraintEqualToAnchor:guide.trailingAnchor].active = YES; | |
[self.demoView.topAnchor constraintEqualToAnchor:guide.topAnchor].active = YES; | |
[self.demoView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor].active = YES; |
This file contains 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
demoView.translatesAutoresizingMaskIntoConstraints = false | |
if #available(iOS 11.0, *) { | |
let guide = self.view.safeAreaLayoutGuide | |
demoView.trailingAnchor.constraint(equalTo: guide.trailingAnchor).isActive = true | |
demoView.leadingAnchor.constraint(equalTo: guide.leadingAnchor).isActive = true | |
demoView.bottomAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true | |
demoView.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true | |
} else { | |
NSLayoutConstraint(item: demoView, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true | |
NSLayoutConstraint(item: demoView, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true |
This file contains 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
private static func value<T>(valueRaw: LoginResponse) -> T { | |
return valueRaw as! T | |
} |
This file contains 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
private static func value<T>(valueRaw: LoginResponse) -> T { | |
guard let castedValue = valueRaw as? T else { | |
fatalError("Unable to cast \(valueRaw) to \(T.self).") | |
} | |
return castedValue | |
} |
This file contains 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
private static func value<T>(valueRaw: LoginResponse) -> T? { | |
return valueRaw as? T | |
} |
This file contains 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
enum ErrorsWhenCasting : Error { | |
case wrongType | |
} | |
private static func value<T>(valueRaw: LoginResponse) throws -> T { | |
guard let castedValue = valueRaw as? T else { | |
throw ErrorsWhenCasting.wrongType | |
} | |
return castedValue | |
} |
OlderNewer