Skip to content

Commit

Permalink
Update 025-20240722.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sookim-1 authored Jul 22, 2024
1 parent 360be08 commit 7ec8361
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Content/posts/025-20240722.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
date: 2024-07-22 14:00
description: JSON 기본값 처리, CocoaPod 비공개저장소 배포, TabBar 멀티터치, WebView UserAgent
tags: iOS, Swift, JSON, Cocoa Pods, WebView, TabBar
tags: iOS, Swift, JSON, Cocoa Pods, WebView, TabBar, REST API
---
# 번호 : 025, 작성일자: 2024-07-22
## 2024.07.15 ~ 2024.07.21
Expand All @@ -11,7 +11,9 @@ tags: iOS, Swift, JSON, Cocoa Pods, WebView, TabBar
현재 회사에서는 서버에서 응답받은 JSON의 Codable 모델을 작성했을 때, 키값의 자료형이 다르거나, 없는 키값이 있는 경우 앱이 종료되지 않도록 사전에 설정한 기본값으로 변경해주기 위해 KeyedDecodingContainer의 extension하여 사용 중이였다.

하지만, 특정 요청에서는 null과 기본값을 구분해주고 싶은 경우에도 기본값으로 변경해주기 때문에 Decoder 객체에 구분할 수 있는 프로퍼티를 추가해주고 해당 프로퍼티값을 바라보면서 상황에 따라 구분할 수 있도록 코드를 수정했다.

해당 코드를 수정할 때 Mock API를 만들기 위해 🔗 [**Insomnia**](https://insomnia.rest/)툴을 사용했는데 매우 간편해서 자주 사용할 것 같다.

자주 사용할 수도 있다고 생각하여 🔗 [**KeyedDecodingContainer+Extension.swift**](https://gist.github.com/sookim-1/24118584ae49a5c1f5d11e03a4c50de9) 관련 코드를 gist에 추가했다.

### ⚙️ private cocoapod 배포
Expand All @@ -33,4 +35,4 @@ private pod으로 배포하기 위해서는 Library Repository와 Spec Repositor
---

1. 탭바 아이템 여러개를 동시에 터치했을 때 UITabBarControllerDelegate의 animation 처리하는 메서드에서 이슈가 발생했는데 기본적으로 탭바를 구현할 때 멀티터치를 제한하도록 해야겠다.
2. WebView 관련 코드리뷰 중 🔗 [**customAgent**](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent)와 🔗 [**applicationNameForUserAgent**](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1395665-applicationnameforuseragent) 2가지를 설정하는 부분이 있어서 2개의 차이에 대해서 알아보았다. userAgent를 customAgent는 통째로 변경하고 applicationNameForUserAgent는 userAgent 끝에 추가 하지만 웹사이트에 따라서 값이 제대로 설정되지 않을 수 있어서 customAgent로 설정하는 부분이 안전하고 중복으로 변경하지 않을 수 있는 것 같다.
2. WebView 관련 코드리뷰 중 🔗 [**customAgent**](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent)와 🔗 [**applicationNameForUserAgent**](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1395665-applicationnameforuseragent) 2가지를 설정하는 부분이 있어서 2개의 차이에 대해서 알아보았다. userAgent를 customAgent는 통째로 변경하고 applicationNameForUserAgent는 userAgent 끝에 추가하는 방식이였다. 하지만 applicationNameForUserAgent는 웹사이트에 따라서 값이 제대로 설정되지 않을 수 있어서 customAgent로 설정하는 방법이 안전한 방법 같다.

0 comments on commit 7ec8361

Please sign in to comment.