오늘도 어김없이 오류를 내었음. 높은 우선순위의 작업(User-initiated)이 낮은 우선순위 작업(default)을 기다리고 있으니까 이 우선순위 역전을 피할 수 있는 방법을 찾아라 뭐 그런거 같음오류를 보면 Data(ContentsOf)에서 나는 것을 볼 수 있었음. Thread Performance Checker: Thread running at User-initiated quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions[NSData(NSData) initWithContentsOfURL:..
프로젝트 중에 네트워크가 끊어지는 상황에 대해서 생각해 보게 되었음 네트워크가 켜져 있지 않거나 비행기모드라면, 네트워크 연결이 필요한 부분(API 콜을 한다던가, 사진을 다운받는다던가) 하는 곳에서 에러가 날 것임. 하지만 이 부분에 대해서 예외처리가 되지 않는다면 사용자 경험측면에서 좋지 않다는 생각을 했음 그래서 네트워크 단절에 대한 처리를 해보게 되었음일단 아래와 같은 NetworkView를 만들고 네트워크 통신이 일어나는 모든 뷰 컨트롤러에 추가해놓았음그리고 아래와 같이 별도로 NetworkMonitor 클래스를 만들어서 startMonitoring을 호출하는 시점부터 계속해서 네트워크 상태를 감지하도록 했음import Foundationimport Networkfinal class Networ..
ColelectionView를 구성하는 API는 3가지의 카테고리로 나눌 수 있음Data / Layout/ Presentation임. 데이터를 어떤 레이아웃으로 어떻게 표현해줄 것인가? 대충 뭐 그런것같음iOS6에 처음 도입되었을 때 데이터는 "indexPath"기반의 UICollectionViewDataSource 프로토콜 기반으로 관리되었음그리고 Layout에는 UICollectionViewFlowLayout을, Presentation쪽에는 UICollectionViewCell이나UICollectionViewReusable을 제공했다고 함.자 그 다음 iOS13에는 Data와 Layout 에 DiffableDataSource, CompositionalLayout을 도입함iOS14에서는 세가지 카테고리..
Realm을 처음 알게되고 사용했을 때는 편리하다는 생각이 컸는데 쓰다보니 생각보다 고려해야 할 지점이 많다고 생각이 들었음개발하면서 마주친 문제점과 해결한 방식들을 써보려고 함 일단 개발한 앱은1) 검색을 하면 네이버쇼핑API로 상품정보를 불러와서 보여줌 (네트워크 통신)2) 그 다음 좋아요를 누르면 Realm에 해당 상품이 저장됨 (DB 저장) 사실 상품 ID로 정보를 조회할 수 있는 API가 있다면 똑같이 네트워크 통신을 통해 해결하면 되는 일이지만, 없다는 게 문제임. 그렇다면 내부적으로 Realm으로 저장하는 방법을 사용할 수 밖에 없음. 어쨌든 그래서 문제는 뭐냐면 1. 네트워크 통신에서 받아온 데이터는 Realm Object가 아님아래 화면은 네이버 쇼핑 API로 조회한 결과값임. API로 ..
Data(contentsOf:) 란? 특정 URL로 부터 Data를 만드는 생성자임근데 그 아래 안내문이이 방법은 동기식으로 실행되며 호출 스레드가 끝날 때까지 차단되므로 main 스레드에서 호출하지 마십시오.대신 file coordination 또는 nonblocking file-related APIs 중 하나를 사용하십시오. 자세한 내용은 파일 시스템에 액세스할 때 성능 및 안정성 향상을 참조하십시오.일단 동기적으로 실행된다는 데서 해당 작업이 끝날 때까지 스레드는 일을 하지 못한다는 것을 알 수 있음작업이 끝날때까지 아무 것도 할 수 없기 때문에 계속해서 사용자의 이벤트를 업데이트 해주어야 하는 메인스레드에서는 호출하면 안됨 여기까지 이해하고 그럼 단순하게 DispatchQueue.global()...
다마고치를 키우는 앱을 만들다가 모델을 struct에서 class로 변경하였는데 didSet이 되지 않는 현상이 생김단지 struct에서 class로 변경한 것 뿐 모든게 동일했는데 왜 안되는 걸까 일단 코드를 살펴보면struct TamaStruct { let name = "TAMATAMA" var rice = 0 var water = 0}class TamaClass { let name = "TAMATAMA" var rice = 0 var water = 0}var tamaStruct = TamaStruct(){ didSet { print("tamaStruct 변경됨") }}var tamaClass = TamaClass(){ didSet { ..
WWDC2022에 소개된 프로토콜 인터페이스 설계 방법개요1. understand type erasure : 연관타입을 가진 프로토콜이 실존타입과 작용하는 방법(타입 소거)2. hide implementation details: 불분명한 결과 타입을 인터페이스 구현하여 캡슐화를 개선하는 방법3. identify type relationships : 프로토콜의 동일 타입 요구사항이 여러개의 서로 다른 구체타입 집합 관계 모델링 하는 방법1. understand type erasureprotocol Animal { associatedtype CommodityType: Food func produce() -> CommodityType}//CommodityType이 Egg인 프로토콜을 따름stru..
앱의 간단한 데이터들을 저장하기 위해 UserDefaults에 대해 알아보고자 함. 정의를 살펴보면 앱이 실행전반에 걸쳐 영구적으로 key-value를 저장하는 데이터베이스라고 함. 개요를 보면 사용자가 앱을 사용할 때의 기본적인 설정(미디어 재생속도) 등을 저장해서 작동방식을 결정함기본적인 객체 저장을 지원하는데 float, double, Int, Bool, URL 같은 것들을 key-value로 저장할 수 있음UserDefaults.standard.set("홍복치", forKey: "name")이런식으로 기본적인 값들을 저장할 수 있다는 것임 property list 형태인 NSData, NSString, NSNumber, NSDate, NSArray, NSDictionary 같은 것들도 저장할 수..
view가 화면에 나타날 준비를 하는 과정1. view의 init(coder:) 메서드를 사용하여 각 뷰를 생성2. action 및 outlet 연결3. 각각의 view와 viewcontroller의 awakFromNib() 메서드 호출4. view계층을 viewcontroller의 view객체에 할당5. viewDidLoad() 호출로드 타임에 viewController를 사용할 수 있게 하는데 필요한 설정단계를 한 번만 수행위의 단계에서 화면에 나타날 때마다 수행되어야 하는 작업은 하면 안됨(애니메이션, 뷰 업데이트 등)화면이 뜰 때 단계별로 함수를 print해보면 위와 같이 출력 되는 것을 볼 수 있음 UIKit은 view가 화면에 표시되면 viewcontroller에게 알려주고 view의 의 레이..
RenderingModeRenderingMode는 말 그대로 이미지에 대해 가능한 렌더링 모드를 지정하는 것RenderingMode는 autoMatic, alwaysOriginal, alwaysTemplate이라는 3가지의 case를 가짐 RenderingMode의 세 종류automatic : context의 기본 랜더링 모드를 이용해 이미지를 그림alwaysOriginal: 템플릿으로 다루지 않고 항상 오리지널 이미지를 그림alwaysTemplate: 이미지의 색상 정보를 무시하고 항상 템플릿 이미지를 그림RenderingMode 사용 이유각 모양 스타일에 맞는 이미지 자산 관리 밎 올바른 이미지를 프로세스를 간소화시키기 위함비트맵 이미지를 만드는 대안으로 템플릿 이미지나 심볼 이미지를..
- Total
- Today
- Yesterday