Browse Questions
  • Firebase Cloud Messaging (FCM) lets you send push notifications to your iOS app through Apple Push Notification service (APNs).
  • The Observer pattern lets objects subscribe to events from another object without tight coupling.
  • An .xcconfig file is a plain text file that sets build settings.
  • Both manage concurrent work, but async/await (introduced in Swift 5.5) is structured and compiler-checked, while GCD is unstructured and callback-based.

Answer: The Observer pattern lets objects subscribe to events from another object without tight coupling. One-to-many event broadcasting.

iOS implementations:

// 1. Combine / @Published (modern, SwiftUI)
class ViewModel: ObservableObject {
    @Published var count = 0
}
// Views automatically observe and re-render

// 2. NotificationCenter (app-wide broadcasts)
NotificationCenter.default.post(name: .userLoggedIn, object: nil)
NotificationCenter.default.addObserver(self,
    selector: #selector(handleLogin),
    name: .userLoggedIn, object: nil)

// 3. Delegate pattern (one-to-one observer)
protocol DownloadDelegate: AnyObject {
    func didFinishDownload(url: URL)
}
class Downloader {
    weak var delegate: DownloadDelegate?
}

// 4. KVO (Key-Value Observing) — mostly Objective-C legacy