Music_Player3/MusicPlayer/MP/Common/Extension(扩展)/Notification.swift

89 lines
3.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Notification.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/1.
//
import Foundation
///
protocol NotificationKey {
associatedtype Keys: RawRepresentable
}
///RawValue
extension NotificationKey where Keys.RawValue == String {
///
static func post(notificationName key:Keys, object:Any? = nil) {
let rawValue = key.rawValue
NotificationCenter.default.post(name: NSNotification.Name(rawValue), object: object)
}
///
static func add(observer: AnyObject, selector: Selector, notificationName key: Keys, object:Any? = nil) {
let rawValue = key.rawValue
NotificationCenter.default.addObserver(observer, selector: selector, name: NSNotification.Name(rawValue), object: object)
}
///
static func remove(observer: AnyObject, notificationName key: Keys, object:Any? = nil) {
let rawValue = key.rawValue
NotificationCenter.default.removeObserver(observer, name: NSNotification.Name(rawValue), object: object)
}
}
//MARK: -
extension NotificationCenter{
struct notificationKey:NotificationKey {
///
enum Keys:String {
///taBarItem
case switch_tabBarItem
//MARK: - A
///A
case sideA_time_times
///A
case sideA_volume_change
///A
case sideA_play_music
///A
case sideA_stop_music
///A
case sideA_pause_music
///A
case sideA_resume_music
///A
case sideA_open_monitor
///A
case sideA_stop_monitor
///A
case sideA_new_choice
///A
case sideA_creat_music
///A
case sideA_null_music
///A
case sideA_close_show
///A
case sideA_display_show
///A
case sideA_hidden_show
///A
case sideA_rename_music
//MARK: - b
///
case positive_browses_reload
///
case positive_list_reload
///
case switch_player_status
///
case pup_bottom_show
///
case pup_player_vc
///
case positive_player_reload
///
case player_type_switch
///
case player_delete_list
}
}
}