7.3. Defining the names (identifiers) of the Notifications in a Better Way
Last updated
Last updated
//
// NotificationNames.swift
// App7
//
// Created by Sakib Miazi on 5/22/23.
//
import Foundation
extension Notification.Name{
static let textFromScondScreen = Notification.Name("textFromSecondScreen")
}//MARK: observing text if it is updated in NotificationCenter...
notificationCenter.addObserver(
self, selector: #selector(notificationReceivedForTextChanged(notification:)),
name: Notification.Name("textFromSecondScreen"),
object: nil)//MARK: observing text if it is updated in NotificationCenter...
notificationCenter.addObserver(
self, selector: #selector(notificationReceivedForTextChanged(notification:)),
name: .textFromScondScreen,
object: nil)//MARK: posting text to NotificationCenter...
notificationCenter.post(
name: Notification.Name("textFromSecondScreen"),
object: text)//MARK: posting text to NotificationCenter...
notificationCenter.post(
name: .textFromScondScreen,
object: text)