-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#79] 프로토콜 사용해서 리터럴한 값 덜어내기, 상수값 관리하기
- Loading branch information
1 parent
a3139d7
commit 56c7fe1
Showing
7 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Constant.swift | ||
// NetworkBasic | ||
// | ||
// Created by taekki on 2022/08/01. | ||
// | ||
|
||
import Foundation | ||
|
||
//enum StoryboardName: String { | ||
// case Main | ||
// case Search | ||
// case Setting | ||
//} | ||
|
||
struct StoryboardName { | ||
|
||
// 접근 제어를 통해 초기화 방지 | ||
private init() {} | ||
|
||
static let main = "Main" | ||
static let search = "Search" | ||
static let setting = "Setting" | ||
} | ||
|
||
/* | ||
1. struct type property vs enum type property => 인스턴스 생성 방지(열거형은 초기화 x) | ||
2. enum case vs enum static => 중복된 내용을 하드 코딩할 수 있나, case에는 제약이 존재(UIColor, UIImage 사용 x) | ||
*/ | ||
//enum StoryboardName { | ||
//// var nickname = "고래밥" // 인스턴스를 만들지 못하기 때문에 저장 프로퍼티 사용 불가 | ||
// | ||
// // 타입 프로퍼티 사용 가능 | ||
// static let main = "Main" | ||
// static let search = "Search" | ||
// static let setting = "Setting" | ||
//} |
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
26 changes: 26 additions & 0 deletions
26
NetworkBasic/NetworkBasic/Protocol/ReusableViewProtocol.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// ReusableViewProtocol.swift | ||
// NetworkBasic | ||
// | ||
// Created by taekki on 2022/08/01. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol ReusableViewProtocol: AnyObject { | ||
static var reuseidentifier: String { get } | ||
} | ||
|
||
extension UIViewController: ReusableViewProtocol { | ||
// 연산 프로퍼티의 형태로 나옴. | ||
// 연산 프로퍼티 get만 사용한다면 get 생략 가능. | ||
static var reuseidentifier: String { | ||
return String(describing: self) | ||
} | ||
} | ||
|
||
extension UITableViewCell: ReusableViewProtocol { | ||
static var reuseidentifier: String { | ||
return String(describing: self) | ||
} | ||
} |
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
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
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