Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Boost‐SwiftUI‐2024年11月19日(화).md

유정주 JeongJu Yu edited this page Dec 14, 2024 · 3 revisions

원본 텍스트 파일

Boost‐SwiftUI‐2024年11月19日(화).txt


스터디 시간 및 참여자

  • 2024年11月19日 화 오후 9:03 ・ 39분 58초
  • 권승용 김인환 유정주 이준복 이창준 홍승현
  • 클로버노트를 이용해 회의 내용을 기록하고, Claude를 이용해 요약, 편집했습니다.

Understanding Swift Performance 스터디 정리

Value Types vs Reference Types

주요 차이점

  • Value Type(구조체)와 Reference Type(클래스)의 핵심적 차이
    • NS 배열 포함 가능 여부가 주요 차이점 중 하나
    • Value Type은 NS 배열을 내부에 포함할 수 없음
    • Reference Type은 NS 타입을 포함 가능

Value Type의 특성

  • 생성이 가볍고 할당/해제가 단순
  • 멀티스레드 환경에서 더 안전
  • Value Semantics 유지가 중요
    • 구조체 내부에 클래스를 포함하면 Value Semantics 손실
    • 복사 시 독립적인 값 보장

Protocol과 성능

Protocol과 Dynamic Dispatch

  • Protocol 사용 시 성능 고려사항
    • Protocol 타입 선언 시 Dynamic Dispatch 발생
    • Witness Table과 V-Table 탐색으로 인한 오버헤드
    • Container에서 existential container로 힙 저장

Protocol 최적화 전략

  • Generic Protocol vs 일반 Protocol
    • Generic Protocol이 성능상 이점 있음
    • 단, 제약 조건이 까다로움 (단일 타입만 가능)
  • Extension을 통한 최적화
    • Extension에서 구현 시 static dispatch 가능
    • 단, protocol 요구사항 준수 검증 어려움

SwiftUI와 구조체 활용

View Model 설계

  • 클래스 vs 구조체 선택
    • View Model은 클래스가 더 적절할 수 있음
    • 데이터 변경이 잦고 상태 관리가 필요하기 때문
    • @Published 사용을 위해 클래스 필요

UI 컴포넌트 설계

  • Value Type 활용
    • SwiftUI View는 구조체로 구현
    • 가벼운 생성과 복사가 장점
    • UI 컴포넌트의 독립성 보장

최신 Swift 동향

Protocol Oriented Programming

  • Apple의 방향성
    • 상속보다 Protocol과 구조체 조합 선호
    • SwiftUI에서도 Protocol 기반 설계 채택
  • Swift 6부터의 변화
    • Protocol 타입에 'any' 키워드 필수화
    • Existential container 사용으로 인한 성능 고려

실무 적용 사례

Generic 활용 예시

  • 단일 섹션 테이블뷰 데이터소스
    • Hashable 채택한 Generic Type 활용
    • 스냅샷 관리 자동화
    • 단일 섹션일 때 효과적

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /