Skip to content

Commit

Permalink
feat: extension메서드 반환형 수정 (#61)
Browse files Browse the repository at this point in the history
그에 따른 VC instance 생성 구문 변경
  • Loading branch information
dahun-lee-daji committed Jun 22, 2021
1 parent ad64ad7 commit f368be4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import UIKit

extension UIViewController {

static func instantiate(name: String, bundle: Bundle? = nil) -> Self {
static func instantiate(name: String, bundle: Bundle? = nil) -> Self? {
let fullName = NSStringFromClass(self)
if fullName.components(separatedBy: ".").count < 1 {
return nil
}
let className = fullName.components(separatedBy: ".")[1]
let storyboard = UIStoryboard(name: name, bundle: bundle)
return storyboard.instantiateViewController(withIdentifier: className) as! Self
return storyboard.instantiateViewController(withIdentifier: className) as? Self
}

}
6 changes: 2 additions & 4 deletions iOS/issue-tracker/IssueList/IssueCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class IssueCoordinator: NSObject, Coordinator {
}

private func createIssueListVC() {
guard let issueListVC = UIStoryboard(name: StoryBoardName.IssueList.description, bundle: nil)
.instantiateViewController(withIdentifier: IssueListViewController.reuseIdentifier) as? IssueListViewController else {
guard let issueListVC = IssueListViewController.instantiate(name: StoryBoardName.IssueList.description) else {
return
}

Expand All @@ -30,8 +29,7 @@ class IssueCoordinator: NSObject, Coordinator {
}

func pushEditView() {
guard let issueEditVC = UIStoryboard(name: StoryBoardName.IssueEdit.description, bundle: nil)
.instantiateViewController(withIdentifier: IssueEditViewController.reuseIdentifier) as? IssueEditViewController else {
guard let issueEditVC = IssueEditViewController.instantiate(name: StoryBoardName.IssueEdit.description) else {
return
}
issueEditVC.coordinator = self
Expand Down

0 comments on commit f368be4

Please sign in to comment.