Swift 에서 배열 요소를 순회할 때 사용하는 반복문 For-each 와 For-in 의 차이가 궁금해져서 알아보았다. 필자는 For-each 를 즐겨쓰는데, 명확한 차이를 이해하지 않은채 쓰고있었다 (…) 반성하자.
결론부터 말하면..
For-each 는 내부적으로 For-in 을 사용한다. (증거)
Swift 로 iOS 를 개발을 할 때 자주 하는 고민 중 하나는 구조체를 사용 할 것인지 클래스를 사용 할 것인지이다. (1위는 역시 네이밍;;)
Apple 은 Swift 로 코드를 작성하는 경우 “Default Structure!” 를 권장하여서 따르고 있기는 했었는데, 좀 더 명확한 기준을 정리하기 위하여 폭풍 검색, 귀중한 문서를 찾게 되었다.
Swift 5 가 공식적으로 릴리즈 되었다. (벌써?)
Swift 5 릴리즈의 주요 사항인 ABI Stability (너란 놈.. 날 강제로 공부시킴)
iOS 개발을 하다보면 볼 수 있는 값의 부재를 나타내는 null / NSNull / nil / Nil.
UIView 내의 레이아웃 관련 메소드인 layoutIfNeeded() / setNeedsLayout(). 두 메서드 모두 layoutSubViews()를 호출하는 메소드이다.
먼저, layoutSubViews()에 대해 알아보자.
layoutSubviews()
UIView와 UIViewController를 상속하여 지정이니셜라이저를 작성할 때, 다음과 같은 에러와 마주하게 된다.
‘required’ 이니셜라이저인 ‘init(corder:)’를 정의해주어야 한다는 에러인데, 다음과 같이 정의만 해주면 에러 문구는 사라진다.