Swift 为什么此行NSNotificationCenter.defaultCenter().postNotificationName(…)抛出SIGABRT
我在斯威夫特的NSNotificationCenter玩。这是我在Swift 为什么此行NSNotificationCenter.defaultCenter().postNotificationName(…)抛出SIGABRT,swift,nsnotificationcenter,xcode6,Swift,Nsnotificationcenter,Xcode6,我在斯威夫特的NSNotificationCenter玩。这是我在main.swift中的代码 进口基金会 class T: NSObject { func someAction(notification: NSNotification) { println(notification.userInfo) } } var dataDict = Dictionary<String, String>() dataDict["test"] = "test"
main.swift中的代码
进口基金会
class T: NSObject {
func someAction(notification: NSNotification) {
println(notification.userInfo)
}
}
var dataDict = Dictionary<String, String>()
dataDict["test"] = "test"
dataDict["test1"] = "test1"
var t = T();
NSNotificationCenter.defaultCenter().addObserver(t, selector:"someAction", name: "someAction", object:nil)
NSNotificationCenter.defaultCenter().postNotificationName("someAction", object:nil, userInfo:dataDict)
let runloop = NSRunLoop.currentRunLoop();
runloop.run();
println("Done");
当我尝试检查该实例时,我得到以下结果:
(lldb) po 0x1005005a0
4300211616
看起来变量已经超出了范围。这是一个正确的结论吗
上面的代码有什么问题?选择器应该是someAction:
而不是someAction
,因为它只有一个参数。谢谢您的快速回答!它起作用了。那么,我应该如何解释po输出?实例没有超出范围吗?
(lldb) po 0x1005005a0
4300211616