//
// VIEwController.swift
// TestNotify
// Created by huangtao on 2017/6/30.
// copyright © 2017年 huangtao. All rights reserved.
// Swift 3.0
import UIKit
class VIEwController: UIVIEwController {
@IBOutlet weak var btnSend: UIbutton!
overrIDe func vIEwDIDLoad() {
super.vIEwDIDLoad()
btnSend.addTarget(self,action: #selector(btnSendFun(_:)),for: UIControlEvents.touchUpInsIDe)
NotificationCenter.default.addobserver(self,selector: #selector(notifyFun(note:)),name: NSNotification.name(rawValue:"test"),object: nil);
}
func notifyFun(note:Notification){
print(" note:\(note.object as! String)")
}
func btnSendFun(_ btn:UIbutton) {
NotificationCenter.default.post(name: NSNotification.name(rawValue:"test"),object: "111111");
}
deinit {
NotificationCenter.default.removeObserver(self);
}
overrIDe func dIDReceiveMemoryWarning() {
super.dIDReceiveMemoryWarning()
// dispose of any resources that can be recreated.
}
}
总结以上是内存溢出为你收集整理的Swift: NotificationCenter 用法 --- swift3.0全部内容,希望文章能够帮你解决Swift: NotificationCenter 用法 --- swift3.0所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)