<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by hyeseong on Medium]]></title>
        <description><![CDATA[Stories by hyeseong on Medium]]></description>
        <link>https://medium.com/@hyeseong7848?source=rss-2a94116a0d0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s9eaCmU_Qvd6hbZ_CNYnTQ.png</url>
            <title>Stories by hyeseong on Medium</title>
            <link>https://medium.com/@hyeseong7848?source=rss-2a94116a0d0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:15:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hyeseong7848/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[현재 ViewController 종료하며 이동]]></title>
            <link>https://medium.com/@hyeseong7848/tttt-8a2a0a695c1b?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a2a0a695c1b</guid>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Tue, 28 Nov 2023 05:04:55 GMT</pubDate>
            <atom:updated>2023-12-14T07:51:21.535Z</atom:updated>
            <content:encoded><![CDATA[<p>개발하며 현재 VC 를 종료 하며 다른 VC 로 이동해야 되는 상황이 발생했다.필자의 경우 게시글 작성 VC 에서 작성을 완료 했을 경우 작성한 글 상세 VC 로 이동해야 되는 상황이다. 사용자의 측면에서 글 작성이 완료한 후에 다시 작성 중인 화면을 봐야 될 필요는 없을 것이다. 따라서 상세 VC 에서 뒤로가기 버튼을 눌러도 게시글 작성 VC 로 이동이 되지 않게 막아야 했다.</p><ol><li>첫번째 시도 방법</li></ol><p>dismiss 메서드에 있는 Closure 를 이용하면 되지 않을까?</p><pre>dismiss(animated: false) {<br>  present(DetailViewController(), animated: false)<br>}</pre><p>동작하지 않았다. dismiss 메서드가 실행 되면서 현재 VC 인스턴스가 제거되어 Closure 구문이 실행하지 못한 것 같다.</p><p>2. 두번째 시도 방법</p><p><a href="https://developer.apple.com/documentation/uikit/uiviewcontroller/1621430-presentingviewcontroller">presentingViewController | Apple Developer Documentation</a></p><p>presentingViewController</p><p>: The view controller that presented this view controller.</p><p>문서에서 설명해주듯이 현재VC 를 제공한 VC 이다.</p><pre>guard let pvc = presentingViewController else { return }<br>dismiss(animated: true) {<br>  let vc = DetailViewController()<br>  pvc.present(vc, animated: false)<br>}</pre><p>presentingViewController 를 활용해 해결하였다.</p><p>참고 블로그</p><ul><li><a href="https://velog.io/@leedool3003/iOS-dismiss-%ED%95%98%EA%B3%A0-present-%EB%84%98%EC%96%B4%EA%B0%80%EA%B8%B0-Presented-vs-Presenting-ViewController">[iOS] dismiss 하고 present 넘어가기 (Presented vs Presenting ViewController)</a></li><li><a href="https://developer-fury.tistory.com/56">[Swift] dismiss 한 뒤 바로 present 하는 방법</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a2a0a695c1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxSwift) Subject (Feat. Relay)]]></title>
            <link>https://medium.com/@hyeseong7848/rxswift-subject-feat-relay-98e764b87c23?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/98e764b87c23</guid>
            <category><![CDATA[relay]]></category>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[subject]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Sun, 12 Nov 2023 12:17:02 GMT</pubDate>
            <atom:updated>2023-11-12T12:17:02.058Z</atom:updated>
            <content:encoded><![CDATA[<p>RxSwift 학습을 하며 항상 큰 흐름은 알고 진행해야 새로운 내용을 학습해도 좀 더 이해가 잘되기 때문에 큰 흐름부터 다시 잡아보겠다.</p><p>RxSwift 이벤트 전달방식</p><ul><li>Observable 은 이벤트를 전달, Observer 는 이벤트 처리</li><li>Observer 가 이벤트를 전달 받기 위해 Subscribe (구독)</li></ul><p>Subject 는 Observable + Observer 를 합친 것이다. 이벤트를 전달도 하고 처리도 할 수 있는 역할이다.</p><p>Subject 의 종류에 대해서 알아보자.</p><ul><li>BehaviorSubject</li><li>PublishSubject</li><li>ReplaySubject</li><li>AsyncSubject</li></ul><h4><strong>BehaviorSubject</strong></h4><pre> let behavior = BehaviorSubject(value: 0)<br>        behavior.onNext(10)<br>        behavior.onNext(20)<br>        behavior.onNext(30)<br>        behavior.onNext(40)<br>        behavior.onNext(50)<br>        <br>        behavior.subscribe(with: self) { owner, value in<br>            print(&quot;behavior next - &quot;, value)<br>        } onError: { owner, error in<br>            print(&quot;behavior error&quot;)<br>        } onCompleted: { owner in<br>            print(&quot;behavior complete&quot;)<br>        } onDisposed: { owner in<br>            print(&quot;behavior dispose&quot;)<br>        }<br>        .disposed(by: disposeBag)<br><br>        behavior.onNext(2)<br>        behavior.onNext(3)<br>        <br>        behavior.onCompleted()<br>        <br>        behavior.onNext(9)<br>        behavior.on(.next(10))</pre><p><strong>실행 결과</strong></p><p><em>behavior next — 50</em></p><p><em>behavior next — 2</em></p><p><em>behavior next — 3</em></p><p><em>behavior complete</em></p><p><em>behavior dispose</em></p><p><strong>특징</strong></p><ul><li>초기값 필요</li><li>구독 전에는 아무리 많은 이벤트를 방출 해도 최신 이벤트만 방출</li><li>구독한 이후에는 최신 이벤트를 방출하고 새로운 이벤트를 방출</li><li>onCompleted() 호출 후에는 dispose 되어 더이상 값을 방출할 수 없음</li></ul><h4><strong>PublishSubject</strong></h4><pre>let publish = PublishSubject&lt;Int&gt;()<br>        publish.onNext(10)<br>        publish.onNext(20)<br>        publish.onNext(30)<br>        publish.onNext(40)<br>        publish.onNext(50)<br>        publish.subscribe(with: self) { owner, value in<br>            print(&quot;publish next - &quot;, value)<br>        } onError: { owner, error in<br>            print(&quot;publish error&quot;)<br>        } onCompleted: { owner in<br>            print(&quot;publish complete&quot;)<br>        } onDisposed: { owner in<br>            print(&quot;publish dispose&quot;)<br>        }<br>        .disposed(by: disposeBag)<br><br>        publish.onNext(2)<br>        publish.onNext(3)<br>        <br>        publish.onCompleted()<br>        <br>        publish.onNext(9)<br>        publish.on(.next(10))</pre><p><strong>실행 결과</strong></p><p><em>publish next — 2</em></p><p><em>publish next — 3</em></p><p><em>publish complete</em></p><p><em>publish dispose</em></p><p><strong>특징</strong></p><ul><li>초기값 없음</li><li>구독한 시점 이후의 이벤트만 방출</li><li>onCompleted() 호출 후에는 dispose 되어 더이상 값을 방출할 수 없음</li></ul><h4><strong>ReplaySubject</strong></h4><pre>let replay = ReplaySubject&lt;Int&gt;.create(bufferSize: 3)<br>        replay.onNext(10)<br>        replay.onNext(20)<br>        replay.onNext(30)<br>        replay.onNext(40)<br>        replay.onNext(50)<br>        <br>        replay.subscribe(with: self) { owner, value in<br>            print(&quot;replay next - &quot;, value)<br>        } onError: { owner, error in<br>            print(&quot;replay error&quot;)<br>        } onCompleted: { owner in<br>            print(&quot;replay complete&quot;)<br>        } onDisposed: { owner in<br>            print(&quot;replay dispose&quot;)<br>        }<br>        .disposed(by: disposeBag)<br><br>        replay.onNext(2)<br>        replay.onNext(3)<br>        <br>        replay.onCompleted()<br>        <br>        replay.onNext(9)<br>        replay.on(.next(10))</pre><p><strong>실행 결과</strong></p><p><em>replay next — 30</em></p><p><em>replay next — 40</em></p><p><em>replay next — 50</em></p><p><em>replay next — 2</em></p><p><em>replay next — 3</em></p><p><em>replay complete</em></p><p><em>replay dispose</em></p><p><strong>특징</strong></p><ul><li>초기값 없음</li><li>구독 전 이벤트를 버퍼 사이즈 만큼 미리 이벤트를 설정 가능</li><li>구독 이후 버퍼 사이즈 만큼 이전 이벤트를 방출</li><li>onCompleted() 호출 후에는 dispose 되어 더이상 값을 방출할 수 없음</li></ul><h4><strong>AsyncSubject</strong></h4><pre>let async = AsyncSubject&lt;Int&gt;()<br>        async.onNext(10)<br>        async.onNext(20)<br>        async.onNext(30)<br>        async.onNext(40)<br>        async.onNext(50)<br>        <br>        async.subscribe(with: self) { owner, value in<br>            print(&quot;async next - &quot;, value)<br>        } onError: { owner, error in<br>            print(&quot;async error&quot;)<br>        } onCompleted: { owner in<br>            print(&quot;async complete&quot;)<br>        } onDisposed: { owner in<br>            print(&quot;async dispose&quot;)<br>        }<br>        .disposed(by: disposeBag)<br><br>        async.onNext(2)<br>        async.onNext(3)<br>        <br>        async.onCompleted()<br>        <br>        async.onNext(9)<br>        async.on(.next(10))</pre><p><strong>실행 결과</strong></p><p><em>async next — 3</em></p><p><em>async complete</em></p><p><em>async dispose</em></p><p><strong>특징</strong></p><ul><li>초기값 없음</li><li>구독한 시점 이후에도 바로 이벤트를 방출시키지 않음</li><li>onCompleted() 호출 후에 최신 이벤트를 방출</li></ul><h4><strong>Relay</strong></h4><p>UI 는 onCompleted / onError 이벤트를 받으면 더이상 onNext 를 받을 수 없기 때문에 Subject 보다 UI 에 적합한 형태가 필요해서 등장했다.</p><ul><li>UI 에 좀더 적합한 형태를 위해 Subject 내부에서 Wrapping 후 제공</li><li>onCompleted / onError 이벤트를 받지 않기 때문에 dispose 되기 전까지 구독이 해제되지 않음.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98e764b87c23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS FCM 연동]]></title>
            <link>https://medium.com/@hyeseong7848/ios-fcm-%EC%97%B0%EB%8F%99-c88c111db8a3?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88c111db8a3</guid>
            <category><![CDATA[fcm]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Sat, 11 Nov 2023 09:56:15 GMT</pubDate>
            <atom:updated>2023-11-12T04:33:31.731Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*RS4UKRhTydMZbpC6Bf8MzQ.png" /><figcaption><a href="https://firebase.google.com/docs/cloud-messaging/fcm-architecture">https://firebase.google.com/docs/cloud-messaging/fcm-architecture</a></figcaption></figure><p>FCM(<strong>Firebase Cloud Messaging</strong>)은 Remote Notification 이다.</p><p>알림에는 Local, Remote 두 가지 방식이 있는데 이 둘의 차이점을 간단하게 알아보고 왜 FCM 이 필요한지 보자.</p><p><strong>Local Notification</strong></p><ul><li>앱 내부에서 알림 전달</li><li>개인이 사용하는 앱에서 주로 사용, ex) Todo 앱, 일기 앱</li><li>무료 개발자 계정으로 테스트 가능</li></ul><p><strong>Remote Notification ( = Push Notification)</strong></p><ul><li>APNs(Apple Push Notification service) 를 통해 알림전달</li><li>앱이 종료된 이후에도 사용자에게 알림이 필요할 때 사용, ex) 채팅, 광고</li><li>유료 개발자 계정 필요</li></ul><p>Remote 방식으로 알림을 구현하기 위해 서버가 필요한데 Firebase 에서 제공해주는 FCM 을 이용하면 클라이언트 개발자도 쉽게 구현할 수 있다. 실제 운영중인 서비스도 자체 서버를 가지고 있지만 다양한 플랫폼을 대응하기가 까다로워 FCM 을 많이 사용한다.</p><p><strong>FCM 연동하기</strong></p><p>1. Firebase 가 연결되어 있는 프로젝트 준비</p><p>2. SPM or CocoaPods - Firebase Messaging 추가</p><p>3. Xcode &gt; App &gt; Capabilities 푸시 알림 사용 설정</p><ul><li>Background Mode - Remote notifications 체크</li><li>Push Notifications</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovQIUMS9Nk5j6H5abG14fg.png" /></figure><p>4. Push 인증키 발급</p><ul><li><a href="https://developer.apple.com/account">인증키 발급 페이지</a> 로 이동 후 [ 키 ] 메뉴 클릭</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hp0B3Kraz0GKlvCoJ6UqDQ.png" /></figure><ul><li>Apple Push Notification service (APNs) 를 선택 후 인증키 발급</li><li><strong>APNs 인증키는 최대 2개까지 발급 가능하고 한번 다운로드 받으면 다시 다운 받지 못하기 때문에 관리를 잘해야 한다.</strong></li></ul><p>5. Firebase Console 이동</p><ul><li>프로젝트 설정 -&gt; 클라우드 메시징 이동</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*Bsvqr_gtXwNz2jIcS9S7Tg.png" /></figure><p>6. p8 인증키 업로드</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*yXBhlXjdCtJKxwXx2yuBgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*RdbLpqPquh9CSdmqS069WA.png" /></figure><ul><li>APNs 인증키에 다운 받았던 p8 인증키 추가</li><li>키 ID 입력 / ex) AuthKey_ABCDEF…. , =&gt; <strong>ABCDEF…</strong></li><li><a href="https://developer.apple.com/account">팀 ID 확인하러 가기</a> 이동 후 멤버십 세부 사항 쪽 팀 ID 확인하기</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMduXGMV4ArtK9b61Tyy2Q.png" /></figure><p>7. Xcode 로 돌아가서 원격 알림 코드 구현</p><p><a href="https://firebase.google.com/docs/cloud-messaging/ios/client?authuser=0">Set up a Firebase Cloud Messaging client app on Apple platforms</a></p><pre>class AppDelegate: UIResponder, UIApplicationDelegate {<br>    <br>    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>        FirebaseApp.configure()<br>        <br>        // 원격알림 등록: 푸시든 로컬이든 알람 허용해야 그 이후에 가능<br>        UNUserNotificationCenter.current().delegate = self<br>        <br>        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]<br>        UNUserNotificationCenter.current().requestAuthorization(<br>            options: authOptions,<br>            completionHandler: { _, _ in }<br>        )<br>        <br>        application.registerForRemoteNotifications()<br>        <br>        // FirebaseMessaging<br>        Messaging.messaging().delegate = self<br>        <br>        return true<br>    }<br>    <br>    // MARK: UISceneSession Lifecycle<br>    <br>    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -&gt; UISceneConfiguration {<br>        // Called when a new scene session is being created.<br>        // Use this method to select a configuration to create the new scene with.<br>        return UISceneConfiguration(name: &quot;Default Configuration&quot;, sessionRole: connectingSceneSession.role)<br>    }<br>    <br>    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set&lt;UISceneSession&gt;) {<br>        // Called when the user discards a scene session.<br>        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.<br>        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.<br>    }<br>    <br>    <br>}<br><br>extension AppDelegate: UNUserNotificationCenterDelegate {<br>    <br>}<br><br>// Firebase<br>extension AppDelegate: MessagingDelegate {<br>    <br>    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {<br>        <br>        let token = String(describing: fcmToken)<br>        print(&quot;Firebase registration token: \(token)&quot;)<br>        <br>        let dataDict: [String: String] = [&quot;token&quot;: fcmToken ?? &quot;&quot;]<br>        NotificationCenter.default.post(<br>            name: Notification.Name(&quot;FCMToken&quot;),<br>            object: nil,<br>            userInfo: dataDict<br>        )<br>    }<br>    <br>}</pre><ul><li>앱 실행 후 MessagingDelegate 에서 Firebase Token 값 확인</li></ul><p>8. Firebase Console - [ Messaging ] 이동</p><ul><li>[ 첫번째 캠페인 만들기 ] - [ Firebase 알림 메시지 ] 선택</li><li>알림 제목과 텍스트 입력 후 테스트 메시지 전송 버튼 클릭</li><li>Firebase Token 등록 필요</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*uxUiPbabvCIb9k4iSRs9Sw.png" /></figure><p>9. Token 등록 후 테스트 메시지 전송 버튼 클릭</p><ul><li>현재 포그라운드 알림을 받도록 따로 처리해주지 않았기 때문에 앱을 백그라운드 상태로 해둔 후 테스트 메시지 전송하기</li></ul><p>10. 정상적으로 연동 되었다면 푸시 알림이 오는 것을 확인할 수 있다.</p><p><strong>번외) </strong>WWDC23 에서 Remote 알림을 테스트 할 수 있도록 애플이 제공한다고 발표 했다.</p><p><a href="https://developer.apple.com/documentation/usernotifications/testing_notifications_using_the_push_notification_console">Testing notifications using the Push Notification Console | Apple Developer Documentation</a></p><ul><li><a href="https://icloud.developer.apple.com/dashboard/notifications/teams/43HXW969NV/app/kr.co.theboms.bom/notifications">테스트 사이트 이동</a></li><li>애플이 제공하는 알림 테스트를 하기위해서는 Device Token 필요</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d49daK1DjiGL_KftT7mIlw.png" /></figure><ul><li>AppDelegate 에 DeviceToken 가져오는 코드 추가</li></ul><pre>extension AppDelegate: UNUserNotificationCenterDelegate {<br>    <br>    /**<br>     Apple 에서 제공하는 푸시 테스트 Token 가져올 때<br>     */<br>    // APNs - DeviceToken 가져오기<br>    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {<br>        <br>        // 앱을 삭제 했다가 다시 깔면 토큰 갱신<br>        let token = deviceToken.map { String(format: &quot;%02.2hhx&quot;, $0) }.joined()<br>        print(&quot;Apple token: &quot; ,token)<br>    }<br>}</pre><ul><li><a href="https://icloud.developer.apple.com/dashboard/notifications/teams/43HXW969NV/app/kr.co.theboms.bom/notifications">테스트 사이트</a> 이동 후 Token 을 입력한 후 왼쪽 상단 Send 버튼을 눌러서 정상적으로 푸시 알림이 오는지 확인</li></ul><p>FCM 은 현업에서 자주 사용 되기 때문에 잘 정리해야 할 것 같다. 연동이 잘되지 않을 때 어느 부분을 빠트리고 했는지 처음부터 차근차근 다시 살펴보자.</p><p>서버, 안드로이드 개발자와 협업하여 같이 개발할 때 안드로이드는 잘 동작하는데 iOS 에서는 푸시가 오지 않을 때는 Firebase Console 이나 애플이 테스트를 제공해주는 곳에서 먼저 테스트 해보고 문제가 클라이언트인지 서버인지 파악 해보자!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88c111db8a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxSwift) Dispose]]></title>
            <link>https://medium.com/@hyeseong7848/rxswift-dispose-408dcc647fee?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/408dcc647fee</guid>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[dispose]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Thu, 02 Nov 2023 10:15:40 GMT</pubDate>
            <atom:updated>2023-11-02T16:01:59.855Z</atom:updated>
            <content:encoded><![CDATA[<p>RxSwift 를 학습하며 예제를 보면 dispose 키워드를 아주 많이 보게 된다. dispose 는 처분하다 라는 의미를 가지고 있다.</p><p><a href="https://medium.com/@hyeseong7848/rxswift-%EC%8A%A4%ED%84%B0%EB%94%94-1-409b05e57047">RxSwift) 큰 흐름 파악하기</a></p><p>RxSwift) 스터디_1 게시글 읽고 왔다면 Observable 의 역할은 이벤트 전달, Observer 의 역할은 이벤트 처리, Observable -&gt; Observer 로 이벤트 전달을 위해 구독이 필요하며 구독을 하면 onNext, onCompleted, onError 같은 메서드로 이벤트를 처리한다는 내용을 알 것이다.</p><p>구독을 시작하면 언제 메모리에서 해지 될까? 만약 dispose 를 사용하지 않고 구독만 하고 있었다면 메모리 누수가 발생했을 것이다.</p><pre>    testValue<br>            .subscribe { value in<br>                print(value)<br>            } onError: { error in<br>                print(error)<br>            } onCompleted: {<br>                print(&quot;complete&quot;)<br>            }<br>            .dispose()</pre><p>위의 코드 마지막 dispose() 에서 메모리에서 해지된다.</p><p>또 <strong>Observable 의 생명주기</strong>가 있는데 구독을 시작하고 onNext 에서 값을 방출하게 되고 onComplete / onError 함수가 호출 되면 dispose() 메서드가 호출되어 메모리에서 해지된다. 따라서 더이상 구독되어 있지 않아도 된다고 판단했을 때 onComplete 를 호출하거나 onError 를 만났을 때 메모리에서 해지된다면 이후 이벤트를 받을 수 없기 때문에 따로 처리를 해줘야된다.</p><p>그렇다면 모든 구독 중인 값을 하나하나 dispose 를 해주어야 될까?</p><p>DisposeBag 클래스가 나타나기 전까지는 하나하나 메모리 해지를 해줘야되었다고 한다.</p><pre>class DisposeBag: Disposable {<br><br>            ...<br><br>  private func dispose() {<br>        let oldDisposables = self._dispose()<br><br>        for disposable in oldDisposables {<br>            disposable.dispose()<br>        }<br>    }<br><br>  deinit {<br>      self.dispose()<br>  }<br><br>            ...<br>}</pre><p>DisposeBag 의 뜻은 폐기가방으로 개발자가 메모리 관리를 편하게 해주기 위해 RxSwift 에서 제공하는 클래스다. 이 클래스의 내부 코드를 보면 deinit 될 때 self.dispose() 메서드를 통해 담아두었던 이벤트들을 모두 메모리에서 해지 시키고 있다.</p><pre>    let disposeBag = DisposeBag()<br><br>    testValue<br>            .subscribe { value in<br>                print(value)<br>            } onError: { error in<br>                print(error)<br>            } onCompleted: {<br>                print(&quot;complete&quot;)<br>            }<br>            .disposed(by: disposeBag)</pre><p>DisposeBag 을 사용하게 된다면 dispose() 메서드로 메모리 해지를 하던 코드를 위의 코드로 바꿀 수 있다.</p><p>DisposeBag 만 사용해주면 이제 메모리 누수에 대한 걱정을 한시름 놓을 수 있게 된다.</p><p>RxSwift 를 잘 사용한다면 좋은 도구가 될 수 있지만 잘못 사용한다면 엄청난 메모리 누수를 겪을 수 있는데 이 부분은 개발시 항상 체크하며 개발해나가야 될 것 같다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=408dcc647fee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxSwift) 큰 흐름 파악하기]]></title>
            <link>https://medium.com/@hyeseong7848/rxswift-%EC%8A%A4%ED%84%B0%EB%94%94-1-409b05e57047?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/409b05e57047</guid>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[reactive]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 05:34:56 GMT</pubDate>
            <atom:updated>2023-11-02T10:16:33.578Z</atom:updated>
            <content:encoded><![CDATA[<p>Swift 는 함수형프로그래밍을 지향 하는 언어이다.</p><p>RxSwift 는 Swift 언어를 반응형프로그래밍으로 개발할 수 있게 도와주는 도구라고 생각하고 학습을 했다.</p><p>반응형프로그래밍으로 개발하도록 도와주는 오퍼레이터들이 있지만 일단 RxSwift 의 큰 내용을 먼저 파악해보자.</p><p>Observable = (이벤트 or 데이터)전달만 하는 녀석.</p><p>Observer = 전달 받은 것을 처리만 하는 녀석.</p><p>Observer 는 이벤트를 전달 받기 위해 Observable 에 구독을 한다.</p><p>구독을 하면 onNext, onCompleted, onError 같은 녀석들로 이벤트를 처리할 수 있다.</p><p>Youtube 를 사용하는 사람이라면 구독을 해본적이 있을 것이다. 구독을 하게되면 구독한 유튜버의 영상이 업로드 되면 알림을 받게되는데 비슷한 시스템이라고 생각하면 이해가 잘되었다.</p><p>유튜브와 합쳐서 생각해보면 Observable 이 영상을 올리게 되면 구독을 한 Observer 는 영상이 업로드 되었다는 알림을 받는다. 여기서 영상을 이벤트라고 생각 해주면 RxSwift 의 기초 이벤트 전달하는 방법이 된다.</p><p>지금까지는 이벤트의 전달 만 다루는 녀석, 이벤트의 처리 만을 다루는 녀석에 대해서만 보았는데 전달도 하고 처리도 해주는 Subject 도 있다. Subject 는 Observable + Observer 로 생각해주면 된다.</p><p>구독을 할 때 Subscribe 대신 Bind, Drive 같은 애들도 있고 이벤트를 처리 하는 메서드도 onNext, onCompleted, onError 말고 Accept 도 있다. Subject 도 BehaviorSubject, PublishSubject 등 여러개가 있다.</p><p>위의 내용들은 현재까지 머릿속에 정리된 Observable 이 이벤트를 전달한 것을 Observer 가 처리할 수 있는데 전달을 받기 위해서는 구독을 해야한다. 이렇게 정리한 내용을 바탕으로 지식을 확장해 나갈 예정이다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=409b05e57047" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[트래블튠 출시 회고]]></title>
            <link>https://medium.com/@hyeseong7848/%ED%8A%B8%EB%9E%98%EB%B8%94%ED%8A%A0-%EC%B6%9C%EC%8B%9C-%ED%9A%8C%EA%B3%A0-eb66b6cc57aa?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb66b6cc57aa</guid>
            <category><![CDATA[traveltune]]></category>
            <category><![CDATA[travel]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 17:12:52 GMT</pubDate>
            <atom:updated>2023-11-02T15:55:52.916Z</atom:updated>
            <content:encoded><![CDATA[<p>출시 프로젝트 준비를 위해 어떤 앱을 만들 것인가 정말 많은 고민을 했다.</p><p>고민 끝에 3가지 정도로 주제를 정했었다.</p><ol><li>원룸,투룸,오피스텔등 부동산 정보 제공 앱</li><li>응급 병상을 실시간으로 확인할 수 있는 앱</li><li>관광지 정보 제공 앱</li></ol><p>이 중에서 2번으로 최종 결정을 하려고 했을 때 멘토님께서 병원과 관련 된 앱을 출시하기 위해서는 의사면허증이 필요하다고 하셨다. 의사면허증이 있을리가 없다…. <strong>애플의 심사 정책을 생각못한 큰 실수</strong>라고 생각한다. 멘토님이 아니었다면 출시 못하는 앱을 개발하고 있었을 것 같다.</p><p>2번이 제외되고 난 후 3번으로 다시 주제를 정했다.</p><p>관광 정보 제공 앱으로 선택 후 단순히 여행지 위치, 이름과 같은 정보가 아닌 좀더 많은 정보를 제공해 주고 싶었다.</p><p>여행 갔을 때 가이드와 같이 다니며 설명을 들으면서 관람 하시는 분들을 보신 적이 있을 것이다. 옆에 슬쩍 같이 들어도 되지만 나만의 가이드가 있으면 좋겠다고 생각했다. 그래서 최종 주제는 관광지 정보/ 관광지 오디오 가이드 정보 제공으로 결정했다.</p><p>해당 주제를 토대로 <strong>초기에 작성된 기능 정리와 기획</strong>이다.</p><ol><li>기능 정리</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*bu55JBNi8JQzVPRhSgwg_A.png" /><figcaption>기능 정리</figcaption></figure><p>2. 기획</p><p><a href="https://jcomet.notion.site/36958e5cc29a453ca49870cac3278000?pvs=4">트래블튠</a></p><p>출시 버전에서 넣고 싶었지만 4주라는 기간동안 구현을 완료해야되기에 이 앱에 있어야 되겠다 싶은 핵심 기능으로 작성했는데 완성할 수 있을지 걱정 되었다.</p><p><strong>개발목표</strong></p><ul><li>MVVM 패턴 적용</li><li>Diffable Data Sources CollectionView 사용</li><li>백그라운드 오디오 재생</li><li>잠금화면 오디오 재생</li><li>MapKit 클러스터링, 커스텀 어노테이션</li></ul><p><strong>개발과정</strong></p><blockquote><strong><em>여러 오픈 소스</em></strong></blockquote><blockquote><em>FSPagerView 는 SPM 을 지원하지 않아 Cocoapods 을 학습해야했는데 Xcode15 버전으로 업데이트를 이미 진행해서 15버전에서 생기는 Cocoapods이슈를 해결후에야 FSPagerView 를 적용할 수 있었다.</em></blockquote><blockquote><em>Tab UI 에 적용한 Parchment 는 부모와 자식 ViewController 간의 데이터가 어떻게 전달되는지 파악하기위해 내부적으로 어떻게 코드가 이루어져있는지 확인후에 데이터 전달에 성공했다.</em></blockquote><blockquote><em>Chart 같은 경우 내부 코드를 가져와서 어떤 부분이 변경 되는지 하나하나 주석처리해가면서 직접 눈으로 보고 원하는 UI 로 수정할 수 있었다. 하나 수정하고 빌드하고 반복하며 시간이 많이 지연 되었는데 많이 사용해보지 않은 오픈소스는 어쩔 수 없는 과정인 것 같다.</em></blockquote><blockquote><em>오픈 소스를 사용하면서 제대로 사용하기 위해서는 항상 내부 코드가 어떻게 이루어져있는지 알아야 다시 요리조리 입맛에 맞게 변경할 수 있다고 느꼈다.</em></blockquote><blockquote><strong><em>Diffable Data Sources CollectionView</em></strong></blockquote><blockquote><em>하나의 기술에 얽매이면 안된다고 이번에 생각했다. 그렇게 복잡하지 않은 UI 인데 학습하기 위해 하나쯤은 제대로 적용시켜 보고 싶었다. 이게 개발시간을 이렇게 많이 잡아먹을 줄 예상을 못했다. 모든 개발이 완료 되었다면 그때 기존 코드를 업데이트 하는 방식이 개발 시간도 줄여주고 학습능률도 올라가는 것 같아 추후에는 기능 개발완료 후 업데이트하는 방식으로 개발을 진행할 것이다.</em></blockquote><p><strong>현재코드의 문제점</strong></p><ul><li>BaseViewController 에서 BaseView, BaseViewModel 을 Generic 으로 받아 사용하는데 어떤 화면에서는 ViewModel 내부 코드가 텅비어있는 클래스가 있다. 아무 역할도 안하는데 그냥 ViewModel 클래스가 만들어져 있는데 개선이 필요하다.</li><li>Label 의 디자인 속성관리가 되어있지 않다. 화면마다 Label 의 디자인이 적용되어 있는데 TitleLabel, ContentLabel, CellLabel .. 이런식으로 관리를 한다면 추후 디자인 변경이 생겼을 때 빠르고 실수 없이 한번에 디자인을 변경할 수 있을 것 같다.</li><li>상수관리가 여기저기 마음데로 되어있다. Extension 으로 빠져 있는 Notification.Name 도 있고 Constant 클래스에서 Font 나 ID 값들이 관리되고 있는데 어차피 상수라면 하나로 관리하는게 추후 헷갈리지 않을 것 같다.</li></ul><p><strong>추후 업데이트 예정</strong></p><ol><li>프로젝트의 구조 코드 정리</li><li>여행일정 관리 기능</li></ol><p>새 기능 추가도 중요하지만 기존에 프로젝트 정리가 더 중요도가 높다고 생각되어 코드를 한번 정리 후 기능을 업데이트할 예정이다.</p><p><strong>마치며..</strong></p><ul><li>Swift 성능을 위해 final 키워드를 사용하고 Reference Count 를 신경쓰며 개발을 했는데 메모리 누수가 없다고 장담을 못하겠다. 분명 어딘가에 빠진 부분이 있을 수 있고 지금 보다 좀더 나은 코드로 성능을 향상시킬 수 있는 방법이 있을 것이다. 항상 Swift 성능을 신경쓰며 앱이 점점 커지더라도 성능에 문제 없는 앱을 개발하기 위해 노력할 것이다.</li><li>하나의 앱을 만들 때 개발자는 사용자가 생각하지 못했던 부분까지 생각해서 미리 대응도 해야되고 버전에 따른 코드 대응도 해주고 해상도 대응도 해야된다. 이것들 말고도 여러가지 버그, 상황별 다른 알림 생각해야 되는 부분들이 너무 많다. 기능을 구현하는데 급급해서 모든 부분에 대해서 대응을 하지는 못했다. 일단 앱이 죽지는 않게 하자는 마인드로 했는데 이러다 보니 놓친 부분이 지금 조금씩 보인다. 개발 실력도 실력이지만 생각의 폭을 좀 넓게 가질 수 있게 연습을 해야될 것 같다.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb66b6cc57aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[트래블튠 트러블슈팅]]></title>
            <link>https://medium.com/@hyeseong7848/%EA%B8%B0%ED%9A%8D%EB%B6%80%ED%84%B0-%EC%B6%9C%EC%8B%9C%EA%B9%8C%EC%A7%80-6051a4143a05?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6051a4143a05</guid>
            <category><![CDATA[traveltune]]></category>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[releases]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 11:03:52 GMT</pubDate>
            <atom:updated>2023-11-02T09:18:59.282Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://apps.apple.com/kr/app/%ED%8A%B8%EB%9E%98%EB%B8%94%ED%8A%A0-%EA%B5%AD%EB%82%B4-%EC%97%AC%ED%96%89-%EC%98%A4%EB%94%94%EC%98%A4-%EA%B0%80%EC%9D%B4%EB%93%9C/id6469851530">‎트래블튠 - 국내 여행 오디오 가이드</a></p><p>Sesac iOS 개발자 교육과정을 2023.07.17 부터 시작해서 하루하루 수업 진도를 놓치지 않기 위해 발버둥 치다 보니 어느새 개인 프로젝트 개발 기간이 되었다.</p><p>개발 기간은 약 한달.</p><p>어떤 앱을 만들지 정한 후 관련 앱과 디자인 그리고 필요한 기능을 정리했다.</p><p>개발 목표는 MVVM 아키텍처를 적용시켜서 최대한 가벼운 ViewController 를 만들자! 라는 목표로 시작했다.</p><p>메인 기능으로는 크게 오디오 재생, 나만의 이야기 (좋아요 기능), 검색, 지도에 관광지 정보 보여주기이다.</p><h3><em>기능별 개발 일지</em></h3><h4><em>1) 오디오 재생</em></h4><blockquote><em>단순 재생을 구현하는데는 관련 블로그와 애플개발자 페이지를 보고 금방 기능을 만들 수 있었다. 하지만 목표는 앱이 백그라운드에 있을 때 재생이 되어야 하고 이때도 유저가 재생/일시정지를 제어할 수 있어야 하는 것이 목표 기능이었다.</em></blockquote><blockquote><em>a) 백그라운드 재생 = Xcode -&gt; Target -&gt; Background Mode 에서 Audio 를 사용설정</em></blockquote><blockquote><em>b) 무음모드 = 테스트 하던 도중 갑자기 소리가 안나서 확인해보니 현재 기기가 무음 모드였다. 무음모드일 때도 동작하도록 AVAudioSession playback 카테고리를 설정해주었다.</em></blockquote><blockquote><em>c) 잠금화면에서 제어 = MPRemoteCommandCenter 를 이용해서 잠금화면에서도 재생/일시정지가 잘동작되는 것을 확인했다.</em></blockquote><blockquote><strong><em>트러블슈팅</em></strong></blockquote><blockquote><em>1. 포그라운드 상태에서 화면의 재생을 눌러 재생상태로 변경</em></blockquote><blockquote><em>2. 백그라운드 상태에서 잠금화면의 일시정지를 눌러 일시정지상태로 변경</em></blockquote><blockquote><em>3. 다시 포그라운드로 돌아왔을 때 </em><strong><em>재생버튼의 이미지는 일시 정지 상태로 변하지 않고있음</em></strong><em>.</em></blockquote><blockquote><em>- LifeCycle 을 이용하면 되지 않을까 싶어서 viewWillAppear 에 print 를 작성해서 포그라운드에서 백그라운드로 돌아올 때 콘솔로 확인했지만 print 문은 보이지 않았다.</em></blockquote><blockquote><em>- SceneDelegate 에서 앱의 백그라운드와 포그라운드를 확인할 수 있는 메서드가 있는 것이 생각나서 sceneWillEnterForeground 메서드에서 NotificationCenter 를 이용해 현재 AVPlayer의 상태를 전달해주도록 수정 후 해결했다.</em></blockquote><blockquote><em>앱 출시 후 추가적으로 알아보니 SceneDelegate 가 아닌 ViewController 내에서 </em>Notification.Name.UIApplication.willEnterForegroundNotification<em>를 이용해 Foreground 상태로 오는 것을 체크 후 재생 이미지를 업데이트 시켜 주면 될 것 같다.</em></blockquote><h4>2) 오디오 데이터 Realm 저장</h4><blockquote><em>메인화면에 테마별로 오디오 파일을 API 통신 후 보여주는 ViewController 가 있는데 사용 중인 API 가 하루에 1000회만 사용할 수 있었다. 테스트하다보면저녁부터 데이터가 안나왔는데 확인해보면 1000회를 다 사용했다는 오류메시지를 확인할 수 있었다.</em></blockquote><blockquote><em>개선을 위해 처음 해당 ViewController 를 실행시 저장한 Realm 데이터가 없다면 API 요청을 한 후 Realm 에 저장시키고 다음부터는 Realm 의 데이터를 사용하도록 수정하였다.</em></blockquote><blockquote><em>이때 서버에서 주는 Response 구조체와 Realm 에 저장할 데이터가 거의 같다고 판단해서 같은 구조체를 사용하기로 했다. Realm 은구조체를 저장할 수 없기 때문에 하나의 클래스로 Response 데이터, Realm 데이터를 사용하기로 했다.</em></blockquote><blockquote><strong><em>개발하면서 계속 불편하다고 느낀점이 있다.</em></strong><em> 하나로 Response 와 Realm 을 관리하니 만들어진 파일은 하나 줄겠지만 화면이 많아 질수록 이게 Realm 에서 가져온 데이터인지 서버통신하고나서 받은 Response 인지 헷갈리기 시작했다. 차라리 각각 Response 용 구조체, Realm 용 클래스를 만들어서 형 변환을 해서 관리하는게 좀 더 좋지않았을까? 하는 생각이 들었다.</em></blockquote><p><a href="https://dev-in-gym.tistory.com/134">Realm swift struct 타입, List타입 수정 하는법</a></p><blockquote><em>앱 출시 후 관련 블로그를 찾아보았는데 추후 업데이트 때 참고하면 좋은 글이다</em>.</blockquote><h4>3) 검색</h4><blockquote><em>a) 검색 기능은 API 호출 후 리스트로 보여주는 부분이라 오래 걸리지 않겠지? 하고 이터레이션을 작성할 때 완료시간도 얼마걸리지 않는다고 해두었는데 UI 를 만들고 데이터를 다루는데 시간이 너무너무 지연되었다.</em></blockquote><blockquote><em>DiffableDataSource 와 CompositionalLayout 를 이용해 UI 를 잡으려고 했다.왜냐하면 첫번째 섹션은 태그셀 디자인, 두번째 섹션은 일반 Vertical 스타일의 셀인데 섹션별로 디자인이 다를 때 이것들을 사용하면 좀 더 쉽게 개발할 수 있다고 기억하고 있어 선택했다.</em></blockquote><blockquote><em>데이터를 업데이트 시키기 위한 구조체의 구조를 잡는데 시간이 오래 걸렸다. 고려해야 될 사항은 사용 되는 데이터는 Hashable 해야되고 , 섹션별로 UI 가 다르고, 첫번째 섹션은 고정적인 데이터, 두번째 섹션은 Realm 데이터와 연동된 가변적인 데이터로 구성해야 한다. 이때 어떤 블로그 글보다 도움이 되었던 코드는 Apple 에서 제공해주는 예제코드이다. 구현은 되었지만 아직까지 제대로 정리가 되지 않아서 추후 학습을 이어나갈 계획이다.</em></blockquote><blockquote><em>b) 검색 결과페이지에서는 Parchment 라이브러리를 활용해 탭UI 를 구성했다. 라이브러리는 설명이 잘되어있어 금방 커스텀 해서 적용을 할 수 있었다. 기존에 구조와는 달라서 데이터를 어떻게 전달할지 고민했다. 부모 ViewController 안에 2개의 자식 ViewController 로 있는 구조로 부모, 자식 ViewController 간의 데이터 전달 할 때 Down Casting 을 통해 부모 -&gt; 자식으로 데이터를 직접 전달 하고 있는데 데이터를 다루는 부분은 웬만하면 ViewModel 로 이관해서 ViewController 의 역할을 줄여야되는데 구현하기에 급급해서 하나씩 ViewController 에서 데이터를 다루고 있기 시작했다. 일단 완성이 목표였기에…</em></blockquote><h4>4) 지도 기능</h4><blockquote><em>API 통신 이후 Mapkit 을 활용해서 지도에 Annotation 과 Clustering 으로 유저에게 보여주는 기능이다. 기본 기능을 구현 후에 오류를 잡는데 오래 걸렸던 기능이다. API 통신이후 이미지를 보여주는 CustomAnnotaionView 를 만들었는데 처음에는 이미지가 잘나오다가 지도를 줌인하며 Clustering 이 동작되고 나서는 기본 이미지로 변경되는 오류가 있었다. CustomAnnotaionView 에서 prepareForDisplay() 를 이용했다. 이 메서드는 View 에 들어가는 값을 미리 설정하는 메서드인데 여기서 image 를 가져오는 작업을 추가로 해주었다. 기존에는 처음 AnnotationView 를 추가해줄 때만 이미지를 추가해서 현재 데이터와 맞지 않는 데이터가 뜰 때도 있고 줌인제스처 이후 이미지가 없어지는 오류가 있었는데 이후 해결되었다.</em></blockquote><h3>마치며..</h3><blockquote><em>넣고 싶은 기능을 전부 넣지는 못했지만 한번 사용해보고 싶은 기능은 넣을 수 있어서 1.0 버전에서는 만족을 하려고 한다. 추후 2.0, 3.0 버전에서는 기능도 기능이지만 좀 더 코드 구조를 개선시켜보려고 한다.</em></blockquote><blockquote><em>기획에 대한 피드백 그리고 이게 맞을까 하는 의구심이 생길 때면 멘토님들에게 질문 후 금방 다시 개발을 할 수 있었는데 멘토님들에게 너무 감사하다는 말을 전하고 싶다.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6051a4143a05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using CocoaPods in Xcode 15]]></title>
            <link>https://medium.com/@hyeseong7848/using-cocoapods-in-xcode-15-41165f053b5d?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/41165f053b5d</guid>
            <category><![CDATA[xcode15]]></category>
            <category><![CDATA[swit]]></category>
            <category><![CDATA[cocoapods]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 14:26:06 GMT</pubDate>
            <atom:updated>2023-11-05T12:55:08.614Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Open Terminal.</li><li>brew install cocoapods.</li><li>From the terminal, navigate to the project file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*hCVILwikpezZO7uY1xWOEg.png" /><figcaption>From the terminal, navigate to the project file</figcaption></figure><p>4. Paste the code below</p><pre>pod init</pre><p>5. Enter ls and you can see the Podfile added</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*lYkjFbNd0A8rM87jU8LcYw.png" /><figcaption>PodFile added</figcaption></figure><p>6. Open Podfile and Edit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Qi4I1jR4vtBrnEoBUds-aw.png" /><figcaption>FSPagerView added</figcaption></figure><p>7. Save Podfile and Close Xcode</p><p>8. Open the terminal that created the Podfile before and enter the code below</p><pre>pod install</pre><p>9. Installation Successful</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8te9B7JlkcPQOJpxcr5rw.png" /></figure><p>10. Now open the project, <em>[YOUR PROJECT NAME].</em><strong><em>xcworkspace</em></strong></p><p><em>You must open a file in xcworkspace</em></p><p>11. Then you can see the Pods</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*0SVllKHktwdYZ3w7NLQ8mg.png" /></figure><p>12. Build and Error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*6DuIQ6LlorQ4Z3IvWBkQvg.png" /></figure><p>13. Increasing the minimum deployment target</p><ul><li>Open your Podfile and Edit</li><li>Add the code below to post_install…</li><li>Code currently setting the minimum version to version 13</li><li>Change to the minimum version you want</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1R_k0ZVpXLybOpr_HRK6Q.png" /></figure><pre>post_install do |installer|<br>    installer.generated_projects.each do |project|<br>        project.targets.each do |target|<br>            target.build_configurations.each do |config|<br>                config.build_settings[&#39;IPHONEOS_DEPLOYMENT_TARGET&#39;] = &#39;13.0&#39;<br>            end<br>        end<br>    end<br>end</pre><p>14. Open the terminal and update the podfile</p><pre>pod install</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YuNOgeCbMuqR8LSs5EbOFQ.png" /></figure><p>15. If you build, you can see a new error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*GHa9VNTdK0AMH__dC_l0bQ.png" /><figcaption>new Error</figcaption></figure><p>16. Check that ENABLE_USER_SCRIPT_SANDBOXING is disabled in the project’s build settings.</p><ul><li>PROJECT -&gt; Build Settings</li><li>Search enable_user</li><li>User Script Sandboxing: Change ‘YES’ =&gt; ’NO’</li></ul><p>17. Build Success</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41165f053b5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS) ViewController 간의 데이터 전달]]></title>
            <link>https://medium.com/@hyeseong7848/ios-viewcontroller-%EA%B0%84%EC%9D%98-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%A0%84%EB%8B%AC-ec7b46e8a93?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec7b46e8a93</guid>
            <category><![CDATA[notification-center]]></category>
            <category><![CDATA[delegate]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 10:06:02 GMT</pubDate>
            <atom:updated>2023-08-30T13:54:05.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*CBWf8iprSkggO6nGJrbzXQ.png" /></figure><p>ViewController 간의 데이터를 전달 하는 내용을 다뤄보려고 한다.</p><p><em>데이터를 전달하는 방법은 5가지가 있다.</em></p><ol><li><em>Property</em></li><li><em>NotificationCenter</em></li><li><em>Closure</em></li><li><em>Delegate</em></li><li><em>Segue prepare</em></li></ol><p><em>5번 Segue prepare 는 스토리보드를 사용했을 때 전달하는 법인데 이 글에서는 다루지 않겠다.</em></p><p>** 데이터 전달외에 레이아웃을 잡는 코드는 생략하고 작성되었습니다.</p><h3><strong>1. Property</strong></h3><p>프로퍼티에 접근해서 데이터를 전달하는 방법은 다른 방법에 비해 비교적 간단하다. FirstViewController 에서 moveButton 을 누르면 SecondViewController 로 이동하는 코드이다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eddea8720a6fca729886c1b4b1e937e8/href">https://medium.com/media/eddea8720a6fca729886c1b4b1e937e8/href</a></iframe><p>SecondViewController 에 title 프로퍼티를 선언해두고 FirstViewController 에서 이동할 때 프로퍼티에 접근해서 값을 전달할 수 있다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db9cb9bccf5ebb3d36f1fc3204eb49e3/href">https://medium.com/media/db9cb9bccf5ebb3d36f1fc3204eb49e3/href</a></iframe><p>FirstViewController -&gt; SecondViewController 로 데이터 전달은 간단하지만 역으로 SecondViewController -&gt; FirstVoewController 로 전달했을 때 값을 받으려면 다른 방법을 찾아보아야 할 것 같다.</p><h3>2. NotificationCenter</h3><p>이 방법은 observer 를 등록해두고 같은 이름의 신호를 전달 받으면 그때 원하는 함수를 실행시켜주면 된다. 스타크래프트를 해보았다면 프로토스 종족에 옵저버를 떠올리면 되는데 관찰하는 것이라고 생각해주면 된다.</p><p>NotificationCenter 를 이용해서 데이터를 전달해야 할 때는 주의 사항이 있다. 데이터를 보내주는 곳보다 받는 쪽이 먼저 작성되어 있어야 한다.</p><p><strong>코드로 얘기해보면 데이터를 받는 addObserver 함수가 데이터를 보내는 post 함수보다 먼저 등록되어 있어야 한다.</strong></p><p>왜냐하면 데이터를 받는 애는 없는데 데이터를 계속 보내봐야 아무 일도 일어 나지 않을 것이기 떄문이다. 데이터를 받을 준비를 해놓고 보내야한다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecd85ed761b9c705dbb95dbb7413c24b/href">https://medium.com/media/ecd85ed761b9c705dbb95dbb7413c24b/href</a></iframe><p>passButton 을 눌렀을 때 이전 화면으로 되돌아가면서 데이터를 전달해주는 코드이다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6838f61a6195ff67cd0dcf0a1037c166/href">https://medium.com/media/6838f61a6195ff67cd0dcf0a1037c166/href</a></iframe><p>NotificationCenter 로 데이터를 전달할 때는 옵저버만 미리 등록해두면 되기 때문에</p><p>FirstViewController -&gt; SecondViewController -&gt; ThirdViewController</p><p>이렇게 이동하는 화면이 있다고 가정했을 때 ThirdViewController 에서 FirstViewController 로 데이터를 전달하는 것도 가능하다.</p><h3>3. Closure</h3><p>closure 는 <strong>(Named Clousre &amp; Unnamed Closure ) </strong>이름있는 함수, 이름 없는 함수 모두를 뜻하지만 일반적으로 이름 없는 함수를 지칭한다.</p><p>좀더 자세히 알기 위해서는 일급객체에 대해 알아보아야 하는데 해당 게시글에서는 데이터 전달법만 알아보자.</p><p>FirstViewController 에 데이터를 받아서 처리할 코드가 미리 작성되어 있는 것을 확인할 수 있다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27ce73b8ae0336c12e5e2f1c1e3c40d0/href">https://medium.com/media/27ce73b8ae0336c12e5e2f1c1e3c40d0/href</a></iframe><p>SecondViewController 에 선언되어 있는 클로저를 통해서 FirstViewController 에서 데이터를 처리한다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db7cb270ee875e53bd4f23bd52be069e/href">https://medium.com/media/db7cb270ee875e53bd4f23bd52be069e/href</a></iframe><p>클로저에 대해서는 동작 방식에 대해 좁더 학습이 필요해보인다.</p><p>일단 데이터 전달방식에 익숙해지기로 하자.</p><h3>4.Delegate</h3><p>delegate 는 대리자, 위임자라는 뜻으로 대신 해준다는 느낌을 가지고 있다</p><p>하나의 객체가 모든 것을 처리하지 않고 처리할 일을 나눠서 한다고 생각해주면 된다. delegate 가 데이터를 전달하는 방식을 살펴보자.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fe1dc8fd47118f8ea63ab2f07c2bf8f/href">https://medium.com/media/5fe1dc8fd47118f8ea63ab2f07c2bf8f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16bcb9bdff052d38e55b4c990938be20/href">https://medium.com/media/16bcb9bdff052d38e55b4c990938be20/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46357fc860158b2aab6cfa0d0b023d87/href">https://medium.com/media/46357fc860158b2aab6cfa0d0b023d87/href</a></iframe><p>delegate 패턴을 보면 SecondeViewController 에 선언되어 있는 delegate 를 통해 FirstViewController 에서 위임자를 등록후 처리해주고 있다.</p><p>delegate 는 데이터를 받는 쪽에서 <strong>vc.delegate = self 해당 부분을 작성해서 위임자를 꼭 설정해주자.</strong></p><h3>정리</h3><blockquote>4가지 데이터 전달방식에 대해 살펴보았는데 Property 를 통해서 데이터 전달하는 방법은 A -&gt; B 로 주로 사용할 것 같다.</blockquote><blockquote>NotificationCenter 같은 경우는 A -&gt; B -&gt; C 로 이동 후 C 에서 A 로 데이터가 전달을 해야되는 상황에서 필요하다고 생각한다.</blockquote><blockquote>Closure 와 Delegate 는 비슷한 느낌을 받았는데 B -&gt; A 로 데이터를 전달할 때 주로 사용이 되어 질 것 같다. Closure 를 사용하면 코드 길이가 더 간결해진다는 장점이 있고, Delegate 는 extension 과 같이 활용하면 기능별로 코드를 잘 나눠 볼 수 있을 것 같다.</blockquote><blockquote>상황별로 데이터를 전달하는 방법을 고민해보고 적용해보도록 해야겠다.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec7b46e8a93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS) GCD _ DispatchQueue]]></title>
            <link>https://medium.com/@hyeseong7848/ios-gcd-dispatchqueue-7dbfa6bf0c0c?source=rss-2a94116a0d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dbfa6bf0c0c</guid>
            <category><![CDATA[gcd]]></category>
            <category><![CDATA[dispatchqueue]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[concurrent]]></category>
            <dc:creator><![CDATA[hyeseong]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 08:14:41 GMT</pubDate>
            <atom:updated>2023-08-18T08:14:41.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*CBWf8iprSkggO6nGJrbzXQ.png" /></figure><p><a href="https://medium.com/@hyeseong7848/ios-gcd-1-a31d5f469aa5">iOS) GCD (1)</a></p><p>GCD 가 무엇이고 왜 필요하게 되었는지 지난 글에서 알아보았다.</p><p>이번 글은 DispatchQueue 에 대해 알아보자.</p><p><a href="https://developer.apple.com/documentation/dispatch/dispatchqueue">DispatchQueue | Apple Developer Documentation</a></p><blockquote>An object that manages the execution of tasks serially or concurrently on your app’s main thread or on a background thread.</blockquote><blockquote>앱의 기본 스레드 또는 백그라운드 스레드에서 순차적으로 또는 동시에 작업 실행을 관리하는 개체입니다.</blockquote><p>순차적(Serial) 또는 동시(Concurrency)에 작업 실행을 관리해주는 녀석이다.</p><p>순차적 작업은 하나의 작업이 끝나면 다음 작업을 실행하고</p><p>동시에 작업하는 것은 동시에 작업을 같이 하는 것이다.</p><p>DispatchQueue 는 main (Serial) 과 global(Concurrency) Queue 를 가지고 있다.</p><p>sync 는 큐에 작업을 추가했을 때 끝날 때까지 기다리는 것이다.</p><p>async 는 큐에 작업을 추가하고 다른 작업을 할 수 있는 것이다.</p><p><strong>1. main</strong></p><pre>DispatchQueue.main.sync { }      // deadlock<br>DispatchQueue.main.async { }</pre><p><strong>main 은 main 스레드 하나에서 실행된다.</strong></p><p>DispatchQueue 를 사용하지 않고 실행 되었던 코드는</p><p>.main.sync 로 실행한 것과 같다.</p><p>그렇기 때문에 main 에서 main.sync 를 사용하면 무한대기상태에 들어가게 된다. (deadlock)</p><p>따라서 main.sync 를 사용할 때는 주의가 필요하다!</p><p>main.async 는 main Queue 에 대기열로 보내줘! 라고 생각하면 된다.</p><pre>print(&quot;Start&quot;) <br>DispatchQueue.main.async {<br>      for i in 1...10 {<br>           print(i, terminator: &quot; &quot;)<br>         }<br> }<br>        <br>        <br> for i in 11...20 {<br>      print(i, terminator: &quot; &quot;)<br> }<br>print(&quot;End&quot;)</pre><p>이 코드를 실행하게되면</p><blockquote><strong>Start</strong></blockquote><blockquote><strong>11 12 13 14 15 16 17 18 19 20 End</strong></blockquote><blockquote><strong>1 2 3 4 5 6 7 8 9 10</strong></blockquote><p>이런 결과를 얻을 수 있다.</p><p>main.async 에 작성된 코드는 대기열로 보내져서 마지막에 실행된 것을 확인할 수 있다.</p><p><strong>2. global</strong></p><pre>DispatchQueue.global.sync { }<br>DispatchQueue.global.async { }<br><br>// DispatchQueue.global(qos: )</pre><p><strong>global 은 여러 스레드에서 나눠 처리된다.</strong></p><p>global 은 qos 를 받을 수 있는데 작업 실행의 우선 순위를 지정하는 서비스 품질 클래스 이다.</p><p><em>qos = Quality of Service</em></p><p><a href="https://developer.apple.com/documentation/dispatch/dispatchqos/qosclass">DispatchQoS.QoSClass | Apple Developer Documentation</a></p><blockquote><strong>qos 중요순</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKScgJE9C3XncdD8s0pPYQ.png" /></figure><blockquote>global.async or global.sync 이런식으로 qos 없이 바로 사용하게 되면</blockquote><blockquote>default 가 적용된다.</blockquote><p>global.sync 로 코드를 실행시키면 main.sync 와 같은 결과를 얻을 수 있다.</p><pre>print(&quot;Start&quot;)<br>DispatchQueue.global().sync {<br>  for i in 1...10 {<br>      print(i, terminator: &quot; &quot;)<br>    }<br>}<br>        <br>for i in 11...20 {<br>    print(i, terminator: &quot; &quot;)<br>    }<br>print(&quot;End&quot;)</pre><blockquote><strong>Start</strong></blockquote><blockquote><strong>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 End</strong></blockquote><p>global = 다른 스레드 , sync = 동기화</p><p>다른 스레드에서 동기화해서 동작 시켜! 라고 되기 때문에 main.sync 처럼 deadlock 은 피할 수 있지만 이렇게 할꺼면 global.sync 를 굳이 사용하지 않아도 될 것 같다.</p><p>global.async 는 다른 스레드에서 동시에 동작해서 동시에 실행되지만 끝나는 지점은 정확히 알 수 없다.</p><pre>print(&quot;Start&quot;)<br>DispatchQueue.global().async {<br>    for i in 1...10 {<br>        print(i, terminator: &quot; &quot;)<br>    }<br>}<br>        <br>for i in 11...20 {<br>    print(i, terminator: &quot; &quot;)<br>}<br>print(&quot;End&quot;)</pre><blockquote><strong>Start</strong></blockquote><blockquote><strong>11 12 13 1 2 3 14 15 16 17 18 4 5 6 7 8 9 10 19 20 End</strong></blockquote><blockquote><strong>Start</strong></blockquote><blockquote><strong>11 12 13 1 2 14 3 15 4 5 16 17 18 6 7 8 9 10 19 20 End</strong></blockquote><p>실행할 때마다 결과 값이 바뀌는 것을 알 수 있다.</p><p>프로젝트 개발할 때 사용해보고 주의해야할 점을 알아보자.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dbfa6bf0c0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>