[WIL] Sesac 2주차

0

정리

7/23

Things I learned

Launch Screen

애플 정책상으로 Launch Screen에 코드를 작성 할 수 없기때문에 다른 뷰에 로딩화면을 연출하여 launch screen처럼 동작하는걸로 보이게 한다.

Launch Screen constraints

  1. Static View only allowed
  2. Large files (~MB) may not be loaded since there is no time for to load files from memory

UIView

  • .isHidden 사용, 토글 까지 가능
  • textview:
    • , isEditable = false,
    • data detectors 추가 하여 시스템 사용

Formatted

iOS15부터 사용가능 숫자 날자 시간 등의 데이터를 localized string 변환

Functions

함수들의 정확한 반환타입 확인하면서 사용할것

  • append vs appending
  • subtract vs subtracting
  • shuffle vs shuffled

7/24

Things I learned

오픈소스

  • Dependency Managers: CocoaPods, Carthage, Swfit Package Manager 3방식 중 1개로 골라서 설치해야한다. 각 라이브러리마다 다름.
    • Cocoapods: 지원 폭이 넓으나 빌드 속도가 좀 느림
    • SPM: Xcode 내부에 빌트인 된 후 많은 라이브러리들이 지원됨.

Enumeration 열거형

  • switch case 구문과
  • rawValue를 통해 멤버와 값을 따로 관리할 수 있다
  • CaseIterable 프로토콜을 통해 배열처럼 쓸 수 있다
let wordListIterable = InternetSlang.allCases //CaseIterable
print(wordListIterable)

ViewController lifecycle

  • viewIsAppearing → iOS17때 새롭게 추가되었으나 iOS13부터 지원함

New Ideas

  • Open Source package 볼 때 깃에 업데이트 된 간격을 보고 유효성을 판단 할 수 있다. 또한 Contributors 수를 보고 판단도 가능
  • 저작권, 과금체계 확인, 보통 명시만 하면 문제 없음
  • Deployment Target은 프로젝트 레벨을 상속하나 보통 타겟에서 지정함. 워치 아이폰 등에서 다 다를 수 있기 때문
  • Semantic version: Major.Minor.Patch
  • iOS 13이후로 화면전환이 많이 달라짐. full screen → sheet
  • navigation - present modally - current context

Useful Links

https://github.com/WenchaoD/FSCalendar

https://github.com/raulriera/TextFieldEffects

https://github.com/onevcat/Kingfisher

https://github.com/hackiftekhar/IQKeyboardManager

7/26

Things I learned

Enum, Guard, Switch

enum TextFieldType: Int{
    case id = 100,email = 200,password = 300
}

@IBAction func textFieldKeyboardTapped(_ sender: UITextField) {
        //가드 여러개쓰기
        guard let text = sender.text, let value = TextFieldType(rawValue: sender.tag) else{
            //알러트로 대응
            print("text empty")
            return
        }
        switch value {
        case .email:
            print("email \(text)")
        case .id:
            print("id \(text)")
        case.password:
            print("password \(text)")
        }
    }

Storing Persistent Data - UserDefaults

Class/Instance

override func attack() {
        super.attack() //parent class
        print("boss attacks")
    }
//  super.function()을 통해서 상속받은 부모의 기능도 동시에 실행을 하는것.
//    override func viewDidLoad){
//        super.viewDidLoad()
//        print("my viewdidload")
//    }
//

New Ideas

  • 이미 연결된 액션을 추가 뷰로 연결할때 뷰의 디폴트 값으로 연결되기 때문에 이벤트를 확인해야한다
  • 클래스의 멤버는:
    • 프로퍼티(변수)
    • 메소드(함수)

Mission

Class/struct upgrade

Computed-Properties

deinitialization

automaticreferencecounting

Swift) 초기화(Initializers) 이해하기 (3/6) - Initializer Delegation

7/27

Things I learned

TableView Controller

Static: 모두가 같은 화면

설정

Dynamic: 틀은 같지만 내용이 다른화면. 대부분 이 형태를 사용하게 됨

유투브 추천

카카오톡 목록

Header - 배너 등으로 사용

인스타 스토리

Footer

스타일: Plain, Grouped, InsetGrouped (최신)

Section (section,row)

Row

//3가지 필수
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        <#code#>
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        <#code#>
    }
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        <#code#>
    }

cell 을 여러개 만들어놓고 조건문에 따라 변경해서 씀

let cell = tableView.dequeueReusableCell(withIdentifier: settingCell)

Tableview Content 를 dynamic prototype으로 해야 tableview.dequereusablecell(identifier:)이 가능한것 같다. Content 를 Static Cell로 할 경우 위 함수로 tabelcell 생성이 안되는것 같음

  • Tableview style은 생성될때 정해짐으로 추후에 바꿀 수 없음

You set the table style when you initialize the table view (see init(frame:style:)). You can’t modify the style thereafter.

Files

Sandbox

DataContainer

Documents - dev, user both accessible

Library

Temp

System

Extension

공통적으로 쓰이는 뷰들에 대하여 익스텐션을 추가해서 효율성 높이기

  • background
  • alert
  • textfields

New Ideas

  • UserDefault에 Button을 누를때마다 저장 vs ViewCont가 사라질때 모아서 저장?
    • 장단점이 있음. UD는 로컬이라 어차피 빠른데 VC가 사라질때만 저장하면 앱이 갑자기 종료될때 등 상황들에 대응해야함
  • view update는 viewWillAppear에다가 하자. super 빼먹지 말기

7/28

TableView

  • Checkbox를 버튼이 아닌 셀 전체를 이용하여 체크 할 수 있도록 만들어 편의성을 높인다
  • 버튼은 보통 44~정도 여백을 넉넉하게 주어 손이 큰 사용자도 배려한다
  • 서브 메시지를 히든으로 하면 메인은 아래로 내려오지 않기 때문에 스택뷰로 감싼다
  • tableview controller에 cell의 iboutlet 연결을 할 수 없다. 그렇다면 UITableviewCell을 하나 더 만든다

셀 선택후 클래스 지정

  • Cell 클래스 이름과 identifier를 통일하면 덜 혼란스러움

Custom TableView Cell

  1. TableView Controller scene & logic
  2. tableview cell logic, 매칭 → 아울렛
    a. identifier = classname
    b. downcasting as custom cell type

Common Error

  1. identifier match with dequeReusableCell()
  2. assign custom class to table cell not its contentview

TypeCasting

typecasting

Properties

Static = stored type property(acts like lazy) / type method

Lazy = lazy type property

New Ideas

  • Keyboard: cell select vs gesture: cell already has event, so gesture won’t work. so how to deal with it? Scroll down?
    • yeah since tableview inherits scrollview
  • Auto layout: Constraint to margin → considers preset margin for view
  • SFsymbol ios13이상부터 등장. 가끔 과제형에서 iOS13 이전 버전을 명시하면 고려해야함.
    - Configuration scale font 가능

1개의 댓글

comment-user-thumbnail
2023년 7월 31일

좋은 글 감사합니다.

답글 달기