Skip to content

Commit

Permalink
refactor: 변수명을 적절하게 수정 #28
Browse files Browse the repository at this point in the history
  • Loading branch information
bibi6666667 committed Sep 15, 2022
1 parent 5865265 commit 75a66ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
16 changes: 6 additions & 10 deletions IssueTracker/IssueTracker/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import UIKit
class Container {

let environment: ContainerEnvironment
private var objects: [String: Any] = [:]
//
private var registeredObjects: [String: Any] = [:]

init(environment: ContainerEnvironment) {
self.environment = environment
Expand All @@ -21,13 +20,13 @@ class Container {
// 외부 등록 허용??
func register<T>(_ object: T) {
let key = String(describing: type(of: T.self)) // 해당 클래스의 이름을 key값으로 저장
objects[key] = object
registeredObjects[key] = object
}

// let value: Type = container.resolve() 로 사용
func resolve<T>() -> T? {
let key = String(describing: type(of: T.self))
guard let object = objects[key],
guard let object = registeredObjects[key],
let object = object as? T else {
print("\(key)는 register되지 않음")
return nil
Expand Down Expand Up @@ -72,6 +71,9 @@ class Container {
register(reposVC)
}

private func registerIssueModel() {
}

func fetchAccessToken(url: URL) {
environment.oAuthService.fetchToken(from: url) { [weak self] accessToken in
guard let token = accessToken,
Expand All @@ -81,12 +83,6 @@ class Container {
self.environment.githubUserDefaults.setToken(token)
}
}

// func buildRootViewController() -> UIViewController {
// self.environment.githubUserDefaults.getToken() != nil
// ? self.buildViewController(.repos)
// : self.buildViewController(.login)
// }
}

extension Container {
Expand Down
12 changes: 6 additions & 6 deletions IssueTracker/IssueTracker/Repos/Model/ReposModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ class ReposModel {
private let environment: ReposModelEnvironment
var updated: (([Repository]) -> Void)?

private var ReposList: [Repository] {
private var reposList: [Repository] {
didSet {
updated?(ReposList)
updated?(reposList)
}
}

init(environment: ReposModelEnvironment) {
self.environment = environment
self.ReposList = []
self.reposList = []
}

var count: Int {
ReposList.count
reposList.count
}

func getViewData(index: Int) -> Repository {
return ReposList[index]
return reposList[index]
}

func fetchViewData() {
environment.requestRepos() { [weak self] result in
switch result {
case .success(let repositoryList):
self?.ReposList = repositoryList
self?.reposList = repositoryList

case .failure(let error):
print(error)
Expand Down

0 comments on commit 75a66ca

Please sign in to comment.