$0 is a shortcut to mean "first argument" in a closure.
클로저에서 첫번째 인수를 의미하는 약식어 정도 생각하면 될 것 같다.
클로저는 이름 없는 함수를 의미한다. 예를 들어보면 아래와 같다.
let nums = [1,62,33,34]
nums.forEach { print($0) }
//출력 결과
1
62
33
34
참고자료
https://developer.apple.com/forums/thread/124678
What is the '$0' syntax in Swift | Apple Developer Forums
I had a question about the $0 syntax in Swift. Haven't had a chance to use it much, however, I am working with things like filter, flatmap, and compactmap, so I see them more often. Any documentation reference or resources on these topics would be super he
developer.apple.com
'IOS' 카테고리의 다른 글
나만의 iOS 앱 개발 입문 : iOS개발 강의 5주차 (0) | 2022.03.28 |
---|---|
나만의 iOS 앱 개발 입문 : iOS개발 강의 4주차 (0) | 2022.03.22 |
나만의 iOS 앱 개발 입문 : iOS개발 강의 3주차 (0) | 2022.03.15 |
나만의 iOS 앱 개발 입문 : iOS개발 강의 2주차 (0) | 2022.03.08 |
[Swift] 스토리보드 시작점 세팅하는 법 (0) | 2022.03.07 |