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
// MARK: - UI objects | |
private lazy var circleView: UIView = { | |
let view = UIView() | |
view.translatesAutoresizingMaskIntoConstraints = false | |
view.backgroundColor = .red | |
view.clipsToBounds = true | |
return view | |
}() |
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
@IBOutlet weak var circleView: AnimatableCircleView! |
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
@IBOutlet weak var circleView: UIView! |
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 UIKit | |
final class AnimatableCircleView: UIView { | |
// MARK: - Initializers and Life cycle | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
self.setup() | |
} |
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
// Step1: Call posts API | |
group.enter() | |
AF.request(Endpoint.posts).response { response in | |
group.leave() | |
} |
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
// 5 | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.isWaiting = true | |
// Step0: Creating and entering dispatch groups | |
let group = DispatchGroup() | |
group.enter() | |
group.enter() |
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 UIKit | |
import Alamofire | |
final class ViewController: UIViewController { | |
// 1 | |
private struct Endpoint { | |
static let posts = "http://jsonplaceholder.typicode.com/posts" | |
static let comments = "http://jsonplaceholder.typicode.com/comments" | |
} |
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 WalkableAnimal { | |
func walk() | |
} | |
protocol RunnableAnimal { | |
func run() | |
} |
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 Animal { | |
func walk() | |
func run() | |
} | |
extension Animal { | |
func run() { | |
} |
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 | |
@objc protocol Animal { | |
func walk() | |
@objc optional func run() | |
} | |
class Elephant: NSObject, Animal { | |
func walk() { | |
print("I am walking") |