새소식

iOS/Swift

[Swift] NotificationCenter

  • -

https://developer.apple.com/documentation/foundation/notificationcenter

 

NotificationCenter | Apple Developer Documentation

A notification dispatch mechanism that enables the broadcast of information to registered observers.

developer.apple.com

 

NotificationCenter


  • 다른 객체 간에 메세지를 보내고 받을 수 있는 능력을 제공하는 클래스
  • addObserver(_:selector:name:object:)로 이벤트를 대기 시킴

  • NotificationCenter.default.post(name: NSNotification.Name("이름"))
    → 
  • @objc selector 함수를 호출하여 이벤트를 발생 시킴

 

 

728x90

'iOS > Swift' 카테고리의 다른 글

[Swift] UserDefault  (0) 2023.07.15
[Swift] Task, await, async  (0) 2023.05.20
[Swift] Localizable  (0) 2023.03.18
[Swift] 제네릭  (0) 2023.03.15
[Swift] for문  (0) 2023.02.07
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.