본문 바로가기

전체 글55

[WWDC22] Design protocol interfaces in Swift Understand type erasure associatedtype을 가진 프로토콜이 어떻게 실존 타입과 상호작용할까?🤔 - 닭은 달걀을 낳고 소는 우유를 만들어낸다. 이를 한번 더 추상화해보자. (associatedtype) - 이를 다이어그램으로 나타낸다면 아래와 같다. - protocol의 Self타입은 Animal protocol을 채택하는 actual concrete type. - protocol Self타입은 Commodity라는 'Food'를 채택하는 associatedtype을 가지고 있다. - any Animal을 통해 Animal 프로토콜을 채택하는 동물들을 담을 수 있다. some이게 되면 underlying type이 고정되기 때문에 any를 통해 선언해준다. - any가 가능한 .. 2023. 4. 27.
[WWDC19] Advances in Collection View Layout (Compositional Layout 정리) - 2(完) Advanced Layouts Supplementary items NSCollectionLayoutSupplementaryItem Badges Headers Footers Simplifies using supplementaries Anchored to item or group NSCollectionLayoutAnchor host space(item or group)에 위와 같이 상대적으로 anchored될 수 있다. 💡 badge는 item(cell)에 붙는 것이므로 item의 supplementaryItems에 들어가야함. Header, Footer header와 footer는 content를 가리는 것이 아니라 콘텐츠 영역을 확장하여 콘텐츠 자체를 볼 수 있도록 하기 위한 것이다. Boundary s.. 2023. 4. 27.
[WWDC19] Advances in Collection View Layout (Compositional Layout 정리) - 1 Compositional Layout Composable: 복잡한 것을 단순한 것들로 구성할 수 있는 Flexible: 어떠한 레이아웃도 작성할 수 있을 정도로 유연한 Fast: 빠른 Composing small layout groups together Layout groups are line-based Composition instead of subclassing (UICollectionViewFlowLayout) subclassing Item, Group, Section, Layout let size = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1), heightDimension: .absolute(44) ) let item = NSColl.. 2023. 4. 27.
[Swift] Closure Capture list, ARC, AnyObject까지 연결지어서 정리 키워드 공부 과제에서 Closure Capture list, ARC, AnyObject에 대해서 알아보는 것이였는데 이를 연결지어서 정리해보았습니다 Closure Capture list var str = "Hello, World!" var myClosure = { [str] in print (str) } str = "next" let inc = myClosure inc() 이 코드를 실행시키면 어떻게 될까요? 답 “Hello, World!”가 출력됩니다 var str = "Hello, World!" var myClosure = { print (str) } str = "next" let inc = myClosure inc() 이 코드를 실행시키면 어떻게 될까요? 답 “next”가 출력됩니다. 이런 일이 벌.. 2023. 4. 23.