전체 글 30

[iOS] RxSwift + Swift Testing

✅ 왜 RxBlocking이 필요할까? RxSwift는 비동기 스트림을 다루는 라이브러리입니다. 하지만 테스트는 동기적으로 결과를 확인해야 합니다// ❌ 이렇게 하면 안 됨 - 비동기라서 테스트가 끝나기 전에 완료됨func test_잘못된_방법() { let result = userRepository.getUser(id: 1) // Single // result는 아직 실행되지 않은 스트림일 뿐! #expect(result == expectedUser) // 컴파일 에러!}// ✅ RxBlocking으로 동기화func test_올바른_방법() throws { let result = try userRepository.getUser(id: 1) .toBlocking() ..

iOS 2025.07.31

[iOS] Factory Pattern

Factory Pattern이 필요한 이유만약 처음에 단순하게 버튼을 이렇게 만들었다// 처음엔 이렇게 만들었지...let button = UIButton()button.setTitle("확인", for: .normal)button.backgroundColor = .blue 그런데 기획자가 와서 말합니다: "아, 이제 라이트 모드랑 다크 모드 두 가지로 만들어주세요!" // 이제 이런 코드가 앱 곳곳에...if isDarkMode { let button = UIButton() button.setTitle("확인", for: .normal) button.backgroundColor = .black button.setTitleColor(.white, for: .normal)} else ..

iOS 2025.07.24

[iOS] Coordinator 패턴 적용기

📚 Coordinator 패턴이란?네비게이션 로직을 View Controller에서 분리하여 별도의 객체가 담당하도록 하는 아키텍처 패턴기존 방식의 문제점View Controller가 다른 View Controller를 직접 생성하고 present/push네비게이션 로직이 여러 곳에 분산되어 관리가 어려움View Controller 간의 강한 결합 Coordinator 패턴의 개념들1. childCoordinators 배열의 역할var childCoordinators = [Coordinator]() // 메모리 관리를 위한 배열메모리 관리를 위한 것배열에 추가 = 메모리에서 해제되지 않게 유지배열에서 제거 = 메모리에서 해제2. coordinator = self를 하는 이유let homeVC = Hom..

iOS 2025.07.22