일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- ios
- SWIFT
- modern concurrency deep dive
- 오블완
- APNS
- WWDC
- 야곰 # 야곰아카데미커리어스타터캠프 #iOS개발자 # 부트캠프
- modern concurrency
- 티스토리챌린지
- Today
- Total
목록전체 글 (71)
Geon
func solution() -> Int{ let X = 5 let A = \[1,3,1,4,2,3,5,4\] var list = Array.init(repeating: 0, count: X + 1) var result = 0 for (index, item) in A.enumerated() { list\[0\] = 1 list\[item\] += 1 if list.allSatisfy({ $0 >= 1}) { result = index break } else { result = -1 } } return result } print(solution()) allSatisfy로 만족하는 결과값을 찾을수 있다.
public func solution(_ A : inout [Int]) -> Int { let removeDuplicate = NSCountedSet(array:A) var result: Int = 0 for i in removeDuplicate { if removeDuplicate.count(for: i) == 1 { result = i as! Int } } return result } let removeDuplicate = NSCountedSet(array:A) for i in removeDuplicate { removeDuplicate.count(for: i) == 1 } 중복된 값이 1인것만 확인할수 있다.
Dependency Inversion Principle (의존성 역전) 상위 수준의 모듈은 하위수준의 모듈에 의존해서는 안된다. 구체적인 사항은 추상화에 의존해야 한다. 왜 하위수준의 모듈에 의존하면 안될까?? 하위수준의 모듈 즉 구체타입은 변화가 많지만 상위모듈인 추상타입은 잘 안변한다. 그래서 DIP를 적용하여 수정시 다른 코드에 영향을 최소화 시킬수 있다. protocol Networkable { mutating func runDataTask(request: URLRequest, completionHandler: @escaping (Result) -> Void) } final class NetworkManager { private var networkable: Networkable init(netw..
Interface Segregation Priciple ( 인터페이스 분리 법칙) 클라이언트는 자신이 사용하지 않는 인터페이스에 의존하지 말아야 한다. 왜 사용하지 않는 메서드에 의존하지 말아야 할까? 불필요한 빌드가 유발될수 있다. protocol 세탁할수있는 { func 세탁하기() func 건조하기() } struct LG세탁기: 세탁할수있는 { func 세탁하기() { print("세탁하기") } func 건조하기() { print("건조하기") } } struct 삼성세탁기: 세탁할수있는 { func 세탁하기() { print("세탁하기") } func 건조하기() { } } 삼성세탁기는 건조하기 기능이 없을수도 있다. 이럴떄는 기능이 없지만 protocol을 채택하고 있기때문에 건조하기 메서드..
defer defer란 연기하다 라는 뜻을가집니다. func deferTest() { print("1") defer{ print("defer") } print("2") } deferTest() // 1 // 2 // defer func deferTest() { defer{ print("defer1") } defer{ print("defer2") } defer{ print("defer3") } } deferTest() // defer3 // defer2 // defer1func deferTest() { defer{ defer { print("defer1") } print("defer2") } defer{ defer { print("defer3") } print("defer4") } } deferTest()..