IOS 65

[iOS / Error] Main Thread Checker: UI API called on a background thread 에러 해결

API를 통해 가져온 데이터로 UI를 업데이트할 때 DispatchQueue.global().async 를 사용했더니 위와 같은 에러가 발생했습니다. 찾아보니, UI 업데이트와 관련된 작업은 main thread에서 실행해야 하는데 background thread에서 실행해서 발생한 에러입니다. Xcode에서 제공하는 runtime tools 중 Main Thread Checker가 있는데 이 tool은 기본 스레드에서 실행해야 하는 시스템 API가 실제로 해당 스레드에서 실행되는지 확인합니다. AppKit 및 UIKit UI API에 적용되며, 일부 다른 시스템 API에도 적용됩니다. 기본 스레드에서 이러한 API를 호출하면 관련 작업의 실행을 직렬화하여 경합 조건을 방지할 수 있습니다. 이는 시각적 ..

Error 2022.01.18

[iOS / Xcode / Console / Log] Class _PathPoint is implemented in both... 로그 분석

Xcode 13으로 업데이트 후 위와 같은 로그가 발생했습니다. 찾아보니 Objective-C로 런타임 시, _PathPoint와 _PointQueue라는 두 개의 동일한 클래스가 생성되어 둘 중 하나를 사용될 것이라는 로그입니다. 따라서 무시해도 상관없는 로그 노이즈라고 합니다. ※ 참고 출처 stackoverflow Class _PointQueue is implemented in both when I click on textfield... How can I resolve this issue? I'm using xcode 13 and making a demo on coredata. objc[6188]: Class _PathPoint is implemented in both /Applications/Xc..

Xcode 2022.01.17

[iOS / Xcode / Console / Log] Writing analzed variants 로그 분석

Xcode 13으로 업데이트 후 위와 같은 로그가 발생했습니다. 사실 해당 로그가 나타나도 빌드나 앱 실행에 영향을 미치는 것 같지는 않았습니다. 찾아보니 해당 로그는 Xcode 로그 노이즈이며 무시해도 상관없다고 합니다. ※ 참고 출처 stackoverflow Xcode log "Writing analzed variants" Running Xcode 13 I see the following log when launching my iOS app in the Simulator: Writing analzed variants. Note that this is, hopefully, a misspelling of the log: Writing analyzed variants. ... stackoverflow.com

Xcode 2022.01.17

[iOS / Swift] 107. Dictionary

107. Dictionary Dictionary 선언 기본 선언 var a = [String: Int]() var a: [String: Int] = [:] var a: [String: String] = ["name": "Lee", "nickName": "kingkong"] Dictionary 활용 초기화 var dictionary = [String: Int]() if dictionary["count"] == nil { dictionary["count"] = 1 } else { dictionary["count"]! += 1 } /* key에 대한 개수를 세고 싶을 때 값이 없다면(nil) 1, 있다면 += 1 */ 수정 var dictionary: [String: String] = ["name": "Lee..

Swift 문법 예시 2022.01.17

[iOS / Swift] 106. Set

106. Set Set 선언 기본 선언 var a = Set() var a: Set = [] var a: Set = ["apple", "banana", "orange"] let a: Set = ["apple", "banana", "orange"] 기본 연산 insert(_ newMember: Element) - 새로운 원소를 저장 contains(_ member: Element) - 특정 원소가 있는지 없는지 판별 remove(_ member: Element) - 특정 원소를 삭제 Fundamental Set Operations var a: Set = ["apple", "banana", "orange"] var b: Set = ["a", "banana", "o"] /* union - 합집합(b U a) ..

Swift 문법 예시 2022.01.17

[iOS / Swift] 105. Array

105. Array 배열 선언 1차원 배열 /* 타입만 설정한 배열 */ let array: [Int] let array: Array /* 빈 값으로 초기화한 배열 */ let array = [Int]() let array: [Int] = [] let array: [Int] = [Int]() let array = Array() let array: Array = [] let array: Array = Array() /* 크기를 고정하고 하나의 값으로 초기화한 배열 */ let array = Array(repeating: 0, count: 5) let array = [Int](repeating: 0, count: 5) /* (문자열도 동일) */ 2차원 배열 /* 타입만 설정한 배열 */ let array:..

Swift 문법 예시 2022.01.17

[iOS / Swift] 104. Strings

104. Strings 문자열 인덱싱 for문 let string = "apple" for index in string.indices { print(string[index]) } 또는 for (index, value) in string.enumerated() { print(index, value) } 또는 string.enumerated().forEach { index, value in print(index, value) } 또는 string.enumerated().forEach { print($0.offset, $0.element) } 직접 접근 let string = "apple" let index = string.index(string.startIndex, offsetBy: 3) /* 3번째 인덱스..

Swift 문법 예시 2022.01.17

[iOS / Swift] 102. Output

102. Output 2차원 배열 정수 - 열은 띄어쓰고 다음 행은 new line let numberArray : [[Int]] = [[1,2,3], [4,5,6]] for i in numberArray { for j in i { print(j, terminator: " ") } print() } 또는 numberArray.forEach { $0.forEach { print($0, terminator: " ") } print() } 또는 for line in numberArray { print(line.map { String($0) }.joined(separator: " ")) } 또는 numberArray.forEach { print($0.map { String($0) }.joined(separato..

Swift 문법 예시 2022.01.17

[iOS / Swift] 101. Input

101. Input 한 줄 정수 하나 입력받을 때 let number = Int(readLine()!)! 문자열 한 줄 입력받을 때 let string = readLine()! n개의 줄, 정수 하나씩 입력받을 때 let n = Int(readLine()!)! var intArray = [Int]() for i in 0 ..< n { let value = Int(readLine()!)! intArray.append(value) } 또는 let n = Int(readLine()!)! var intArray = [Int](repeating: 0, count: n) for i in 0 ..< n { let value = Int(readLine()!)! intArray[i] = value } 또는 let n =..

Swift 문법 예시 2022.01.17