5. 나의 과거와 나의 미래
•공부를 하는 중 (고작 1년 6개월)
•그 때는 그게 최선인 줄 알았기 때문
6. 나의 과거와 나의 미래
•공부를 하는 중 (고작 1년 6개월)
•그 때는 그게 최선인 줄 알았기 때문
•다들 내가 하는게 정답이 아니라는 것을 알기 때문에 발표는 어렵다
7. 나의 과거와 나의 미래
•공부를 하는 중 (고작 1년 6개월)
•그 때는 그게 최선인 줄 알았기 때문
•다들 내가 하는게 정답이 아니라는 것을 알기 때문에 발표는 어렵다
•그래도 아무도 안하면 조금의 개선도 힘드니까
8. 나의 과거와 나의 미래
•공부를 하는 중 (고작 1년 6개월)
•그 때는 그게 최선인 줄 알았기 때문
•다들 내가 하는게 정답이 아니라는 것을 알기 때문에 발표는 어렵다
•그래도 아무도 안하면 조금의 개선도 힘드니까
•알고 있는 만큼만 공유할게요
9. 나의 과거와 나의 미래
•공부를 하는 중 (고작 1년 6개월)
•그 때는 그게 최선인 줄 알았기 때문
•다들 내가 하는게 정답이 아니라는 것을 알기 때문에 발표는 어렵다
•그래도 아무도 안하면 조금의 개선도 힘드니까
•알고 있는 만큼만 공유할게요
•더 나은게 있으면 저도 알려주세요!
•https://dev200ok.blogspot.com
•LEEO TIL DEV LOG
10. AllCase
•사례로 겪어보는 악의 없는 악행들
•1. 나는 이런 의미인 줄 알았는데 아니었네 ( 네이밍 )
•2. 나만 알고있는 접근 제어
•3. If let과 guard let 이 주는 의미
•4. IndexPath.row 와 layout이 주는 의미
•5. 상속할 것들이 많구나 ( 구조 )
11. AllCase
•사례로 겪어보는 악의 없는 악행들
•1. 나는 이런 의미인 줄 알았는데 아니었네 ( 네이밍 )
•2. 나만 알고있는 접근 제어
•3. If let과 guard let 이 주는 의미
•4. IndexPath.row 와 layout이 주는 의미
•5. 상속할 것들이 많구나 ( 구조 )
13. 이름 짓기
•네이밍 문제 import Foundation
struct AdiosStatic {
static let webPageURL =
"https://www.adiOS2021.com"
}
URLSession.shared.dataTask(wi
th: AdiosStatic.webPageURL)
14. 이름 짓기
•네이밍 문제 import Foundation
struct AdiosStatic {
static let webPageURL =
"https://www.adiOS2021.com"
}
URLSession.shared.dataTask(wi
th: AdiosStatic.webPageURL)
15. 이름 짓기
•네이밍 문제
•왼쪽은 url 오른쪽은 string
import Foundation
struct AdiosStatic {
static let webPageURL =
"https://www.adiOS2021.com"
}
URLSession.shared.dataTask(wi
th: AdiosStatic.webPageURL)
16. 이름 짓기
•네이밍 문제
•왼쪽은 url 오른쪽은 string
•사용하는 사람은 URL 일줄
알았는데, String
import Foundation
struct AdiosStatic {
static let webPageURL =
"https://www.adiOS2021.com"
}
URLSession.shared.dataTask(wi
th: AdiosStatic.webPageURL)
17. 이름 짓기
•네이밍 문제
•왼쪽은 url 오른쪽은 string
•사용하는 사람은 URL 일줄
알았는데, String
•물론 IDE가 잘 걸러주긴 합니
다
18. 변수 짓는 건 너무 어려워 ㅠㅠ
•이름을 잘 짓는 방법
•코드 컨벤션
•영어 문법
•애플 감성
19. 이름만 잘 지으면 OK?
•차이점을 아시겠나요? // 1번
var selectedMenu: String
selectedMenu = "pizza"
// 2번
enum Menu: String {
case pizza
case pasta
case salad
}
var selectedMenu2: Menu
selectedMenu2 = .pizza
20. 이름만 잘 지으면 OK?
•차이점을 아시겠나요?
•이름을 똑같이 지어도 다른
느낌
•어떤 의미를 전달하실껀가
요?
// 1번
var selectedMenu: String
selectedMenu = "pizza"
// 2번
enum Menu: String {
case pizza
case pasta
case salad
}
var selectedMenu2: Menu
selectedMenu2 = .pizza
22. 나만 알고있는 접근제어
•접근 제어 관련 문제들
•혹시 나만 알고 있는 비밀이
있나요?
class Life {
func goTimeTravel() {
// traveling
}
func takeDeepSleep() {
// sleep
}
func enjoyVacation() {
goTimeTravel()
takeDeepSleep()
}
}
23. 나만 알고있는 접근제어
•다른 사람은 메소드가 왜
있는지 몰라요
class People {
func makeSomeHobby() {
let life = Life()
life.goTimeTravel()
life.takeDeepSleep()
}
}
24. 나만 알고있는 접근제어
•다른 사람은 메소드가 왜
있는지 몰라요
•있으면 씁니다
•저도 있으면 씁니다
class People {
func makeSomeHobby() {
let life = Life()
life.goTimeTravel()
life.takeDeepSleep()
}
}
25. 개선을 하면 이렇게?
•만들 때 부터 용도 표기
•상속받아도 되는 클래스?
•클래스 내부에서만 쓰이는
건가?
final class Life {
private func goTimeTravel() {
// traveling
}
private func takeDeepSleep() {
// sleep
}
func enjoyVacation() {
goTimeTravel()
takeDeepSleep()
}
}
26. 개선을 하면 이렇게?
•private 가 붙은 함수는 지
울 때 비교적 두렵지 않습
니다.
•final 키워드가 붙어 있으
면 발이 땅에 닿은 느낌입
니다
final class Life {
private func goTimeTravel() {
// traveling
}
private func takeDeepSleep() {
// sleep
}
func enjoyVacation() {
goTimeTravel()
takeDeepSleep()
}
}
28. if let VS guard let
•If let과 guard let 이 주는 의미
29. if let VS guard let
•If let과 guard let 이 주는 의미
•옵셔널 값만 까면 되는걸까요?
•미묘하게 다른 뉘양스
30. if let VS guard let
func printMyName(firstName: String?, lastName: String) {
if let firstName = firstName {
print(firstName, lastName)
}
}
func printMyName2(firstName: String?, lastName: String) {
guard let firstName = firstName else { return }
print(firstName, lastName)
}
31. if let VS guard let
func printMyName(firstName: String?, lastName: String) {
if let firstName = firstName {
print(firstName, lastName)
}
}
func printMyName2(firstName: String?, lastName: String) {
guard let firstName = firstName else { return }
print(firstName, lastName)
}
32. if let VS guard let
func printMyName(firstName: String?, lastName: String) {
if let firstName = firstName {
print(firstName, lastName)
}
// do something
// firstName이 있으면 좋은데... 없으면 뭐
}
func printMyName2(firstName: String?, lastName: String) {
guard let firstName = firstName else { return }
print(firstName, lastName)
// do something
// firstName이 없으면 아무것도 하지마!
}
34. iOS 개발의 시작한지 1개월 차
•IndexPath.row 와 레이아
웃
func tableView(_ tableView:
UITableView, cellForRowAt indexPath:
IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
if indexPath.row == 0 {
// do
return cell
} else if indexPath.row == 1 {
// do
return cell
} else if indexPath.row == 2 {
// do
return cell
}
}
35. iOS 개발의 시작한지 1개월 차
•IndexPath.row 와 레이아
웃
•돌아가는 멀쩡한 코드
•만약 내가 짰다면 이해하기
쉬운 코드
func tableView(_ tableView:
UITableView, cellForRowAt indexPath:
IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
if indexPath.row == 0 {
// do
return cell
} else if indexPath.row == 1 {
// do
return cell
} else if indexPath.row == 2 {
// do
return cell
}
}
36. 그리고 1주일 후...
•얼마 후 개선한 코드
•나름 깔끔 후훗
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell = UITableViewCell()
switch indexPath.row {
case 0:
// do
return cell
case 1:
// do
return cell
case 2:
// do
return cell
default:
// do
return cell
}
}
37. 그리고 1주일 후...
•얼마 후 개선한 코드
•나름 깔끔 후훗
•뭐하는지는 알려줘요
•이게 최선인가요?
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell = UITableViewCell()
switch indexPath.row {
case 0:
// do
return cell
case 1:
// do
return cell
case 2:
// do
return cell
default:
// do
return cell
}
}
38. 그리고 1달 후...
•enum의 활용 방법을
배워 왔다
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell = UITableViewCell()
switch layout[indexPath.row] {
case .headerBanner:
// do
return cell
case .filter:
// do
return cell
case .collectionView:
// do
return cell
default:
// do
return cell
}
}
enum CellType {
case headerBanner
case filter
case collectionView
}
let layout: [CellType] =
[.profile, .filter, .collectionVi
ew]
40. 객체지향 설계 공부
• 내가 공부한 객체지향설계
• 이렇게 구현하면 되겠군
UITableVIew
UIScrollVIew
UIVIew
MyTableVIew
41. 객체지향 설계 공부
• 상속을 너무 많이 받는기분..?
• 우린 애플이 아니야
• 예상되는 미래
UITableVIew
UIScrollVIew
UIVIew
MyTableVIew
42. 내가 만든 작고 강한...
•실제 코드
•이렇게 보면 간단
•심지어 우아해 보이기까지!
class BaseView: UIView {
}
class AnimalView: BaseView {
}
class DogView: AnimalView {
}
class ShibaView: DogView {
}
43. 내가 만든 작고 강한...
•실제 코드
•이렇게 보면 간단
•심지어 우아해 보이기까지!
•AnimalView에 무언가 추가된
다면?
class BaseView: UIView {
}
class AnimalView: BaseView {
func sleep() {
// sleep
}
}
class DogView: AnimalView {
}
class ShibaView: DogView {
}
44. 내가 만든 작고 강한...
•실제 코드
•이렇게 보면 간단
•심지어 우아해 보이기까지!
•AnimalView에 무언가 추가된
다면?
•뭐가 어떻게 되는거지?
class BaseView: UIView {
}
class AnimalView: BaseView {
func sleep() {
// sleep
}
}
class DogView: AnimalView {
override func sleep() {
// sleep
}
}
class ShibaView: DogView {
override func sleep() {
super.sleep()
// sleep
}
}