본문 바로가기

재수강은없다

(77)
[CS193p] Lecture 11 - Persistence에 대해서 2021 CS193P Lecture 11 : Error Handling Persistence 강의 중에서 persistence 관련 강의 내용을 정리한 것입니다. # 데이터를 영구적으로 저장하는 방법 - 파일 시스템에 저장 : FileManager - SQL DB에 저장 : CoreData - iCloud에 저장 - Cloud db에 저장 : CloudKit - 등등 - 설정값 같은 lightweight data : UserDefaults 해당 강의에서는 FileManager와 UserDefaults에 대해서 알아봅니다. # File System iOS의 file system은 UNIX 파일 시스템을 이용합니다. 앱에서 허용된 공간은 sandbox라고 합니다. 이 sandbox 내에서만 읽기와 쓰기가 가..
[CS193p] GCD를 async/await로 변경하기 CS193p 강의의 lec 9, 10에서 GCD를 사용한 것을 new async await로 변경해보겠습니다. 먼저 강의에서 언급한 Swift's new built-in async API는 async/await를 지칭하는 것 같습니다. 2021 WWDC - Meet async/await in Swift javascript의 async/await 구조와 매우 비슷합니다. nest return 코드가 사라져서 가독성이 향상되었습니다. 기존 코드는 다음과 같습니다. private func fetchBackgroundImageDataIfNecessary() { backgroundImage = nil switch emojiArt.background { case .url(let url): // fetch the u..
[iOS, concurrency] publishing changes from background threads is not allowed; Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates. Background queue에서 UI 관련된 작업을 수행하면 다음 문구가 Xcode에 보라색으로 발생합니다. 해당 알람은 런타임에서 확인할 수 있습니다. Main queue에서 실행할 수 있도록 변경해주면 됩니다. 해결방법 다음과 같이main queue에서 async로 동작하도록 했습니다. DispatchQueue.main.async { [weak self] in self?.myText = "blah blah" } 왜 w..
[iOS] GCD, multithreading in iOS 2021 CS193P 강의를 참고하여 작성되었습니다. Threads 하나의 실행 단위입니다. 프로그램 내에서 실행되는 것이 있을 텐데, 그 실행되는 것 하나하나가 모두 스레드입니다. iOS에서 실행되는 스레드는 계속 변경됩니다. 실행되는 스레드 간의 변경이 아주 빠르게 처리해서, 사용자에게는 여러 작업이 동시에 일어나는 것처럼 보이도록 합니다. 아이폰에서 유튜브를 보면서 카카오톡 알림이 오는 것도 다른 스레드들이 계속 스위칭되면서 진행되는 것입니다. 스레드마다 우선 실행권한을 가질 수 있다. Queues 쓰레드는 시간적 개념이 들어가 있기 때문에 코드로 작성해서 이해하는 것이 어렵습니다. Swift에서는 이것을 큐들을 이용해서 해결했습니다. 큐는 실행할 스레드를 순서대로 줄 세워서 처리하게 만듭니다. 개..
[SwiftUI] some View의 some에 대해서 SwiftUI를 처음 시작하면 some 키워드를 접할 수 있습니다. View가 struct라는 것은 알겠는데 앞에 붙은 some이 어떤 역할을 하는 것인지 알아보겠습니다. struct ContentView: View { var body: some View { Text("jsng is here!") .padding() } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } some keyword는 Swift에서 Opaque Types에 해당합니다. 직역하면 불투명한 타입입니다. Opaque Type은 함수나 메서드의 반환 타입을 가리는 역할을 합니다. 특정한 타입을 반환하지 않고 ..
[CS193p] Assignment 4 - Animated Set 솔루션 CS193P Assignment #4 Animated Set 각 task 별 solution을 정리했습니다. All code in github Required Task 1. Your assignment this week must still play a solo game of Set. 2. In this version, though, when there is a match showing and the user chooses another card, do not replace the matched cards; instead, discard them (leaving fewer cards in the game). 👉 card를 선택했을 때의 동작을 replaceNewCard에서 discard로 변경했습니다. m..
[CS193p] Assignment 4 - Animated Set 문제 번역 과제 수행 중에 원본이 영어라서 보고도 까먹는 경우가 많아 한글로 번역합니다. 영한 번역이 아니라 이해한 것을 기반으로 작성한 번역입니다. 2021년 Spring 강의입니다 원본 보러 가기 Objective 이번 과제의 목표는 이전 Set 과제에 animation을 추가해보면서 이번 주에 강의한 animation mechanism을 이해하는 것이 목표입니다. 힌트도 확인하시구요. 평가항목도 확인해주세요. Due 생략 Materials 이전 Set 과제 Required Tasks 이번 과제는 싱글 Set 게임을 계속 만듭니다. 이번 버전에서는 match가 표시되고 나서 유저가 다른 카드를 선택해도, match인 카드를 교체하지 않고 버립니다. (카드 수 감소) "deck"과 "discard pile"을 U..
[CS193p] Assignment 3 - Set Game 솔루션 CS193P Assignment #3 Set Game 각 task 별 solution을 정리했습니다. Required Task 1. Implement a game of solo (i.e. one player) Set 👉 All code in github 2. As the game play progresses, try to keep all the cards visible and as large as possible. In other words, cards should get smaller (or larger) as more (or fewer) appear onscreen at the same ti me. It’s okay if you want to enforce a minimum size for your ..