//通知的使用
1.發通知。(以這條通知為例,通知名字:nicknamenotification 通知引數:title)
nsnotificationcenter.defaultcenter().postnotificationname("nicknamenotification", object: title);2.在要監聽這則通知的viewdidload方法裡面新增觀察者,以便監聽這則通知此處的 title 是要傳的引數
nsnotificationcenter.defaultcenter().addobserver(self, selector: "updatenickname:", name: "nicknamenotification", object: nil);3.實現2中的selector,監聽到通知呼叫的方法
func updatenickname(title:nsnotification)
swift中通知的使用
1.發通知。以這條通知為例,通知名字 gameovernotification。通知引數 title nsnotificationcenter.defaultcenter postnotificationname gameovernotification object title 2.在要監聽這則通...
Swift 函式的基本使用
main.swift testfunctions created by 朱立志 on 14 6 11.import foundation println hello,world 單個引數輸入函式 func sayhello personname string string println sayhe...
swift通知快速建立
相關鏈結 直接監控系統方法 var backgroundobserver nsobjectprotocol?object必須是nil,否則貌似沒反應 backgroundobserver noticecenter.addobserver forname nsnotification.name pri...