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
class SceneDelegate { | |
var navigationController: UINavigationController! | |
... | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let sceneWindow = (scene as? UIWindowScene) else { return } | |
window = UIWindow(windowScene: sceneWindow) | |
window?.makeKeyAndVisible() | |
navigationController = UINavigationController(rootViewController: makeRootViewController()) | |
window?.rootViewController = navigationController | |
} |
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
class ViewControllerA { | |
var onButtonTappedObserve: (() -> Void)? | |
... | |
@IBAction func buttonTapped(_ sender: UIButton) { | |
onButtonTappedObserve?(// dependencies if any) | |
} | |
... | |
} |
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
protocol DatabaseManagement { | |
func insert(_ articles: [Article], completion: @escaping (Result<Bool, Error>) -> Void) | |
func retrieve(completion: @escaping (Result<[Article], Error>) -> Void) | |
func delete(_ article: Article, completion: @escaping (Result<Bool, Error>) -> Void) | |
} |
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
GET *url* | |
200 RESPONSE | |
{ | |
"items": [ | |
{ | |
"id": "a UUID", | |
"title": "a title", | |
"description": "a description", |
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
struct FeedItem { | |
let id: UUID | |
let title: String | |
let thumbnailURL: URL | |
let description: String? | |
let createdDate: Date | |
} | |
struct RemoteFeedItem { | |
let id: UUID |
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
struct User { | |
var id: UUID | |
var accessToken: String? | |
var username: String? | |
var imageURL: URL? | |
var email: String? | |
var address: String? | |
} |
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
class FeedViewModel {} | |
class FeedViewController: UIViewController { | |
private var viewModel: FeedViewModel? | |
init(viewModel: FeedViewModel) { | |
self.viewModel = viewModel | |
super.init(nibName: nil, bundle: 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
class FeedViewModel {} | |
class FeedViewController: UIViewController { | |
private var viewModel: FeedViewModel? | |
override func viewDidLoad(){ | |
super.viewDidLoad() | |
viewModel = FeedViewModel() | |
} |
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
class AllCategoriesViewController: UIViewController { | |
var loader: FeedLoader? | |
func viewDidLoad(){ | |
super.viewDidLoad() | |
loadFeed() | |
} | |
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
protocol FeedLoader { | |
func load(completion: @escaping ([FeedItem]) -> Void) | |
} |