如何通过通知发送号码和字符串...
let mynumber=1;
let mytext="mytext";
NSNotificationCenter.defaultCenter().postNotificationName("refresh", object: ?????????????);
并在接收器中接收值?
func refreshList(notification: NSNotification){
let receivednumber=??????????
let receivedString=?????????
}
你可以把它们包裹在一个NSArray
or a NSDictionary
或自定义对象。
Eg:
let mynumber=1;
let mytext="mytext";
let myDict = [ "number": mynumber, "text":mytext]
NSNotificationCenter.defaultCenter().postNotificationName("refresh", object:myDict);
func refreshList(notification: NSNotification){
let dict = notification.object as! NSDictionary
let receivednumber = dict["number"]
let receivedString = dict["mytext"]
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)