Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 试图传回用户信息时,NSNOTIONG在Swift中中断_Ios_Swift_Notifications_Notificationcenter - Fatal编程技术网

Ios 试图传回用户信息时,NSNOTIONG在Swift中中断

Ios 试图传回用户信息时,NSNOTIONG在Swift中中断,ios,swift,notifications,notificationcenter,Ios,Swift,Notifications,Notificationcenter,我在尝试通过Swift中的postNotification传回用户信息时遇到问题。奇怪的是,只有当我尝试使用userInfo时,代码才会中断——如果我将一个没有数据的通知发布到一个没有参数的选择器,那么一切都会正常工作。但当我尝试传回userInfo时,会出现“无法识别的选择器发送到实例”错误。所以我的ViewController中的选择器签名有问题,但我不知道是什么 以下是中断的代码: 在我的表格视图中 let data = ["selection": selectedOption] dism

我在尝试通过Swift中的postNotification传回用户信息时遇到问题。奇怪的是,只有当我尝试使用userInfo时,代码才会中断——如果我将一个没有数据的通知发布到一个没有参数的选择器,那么一切都会正常工作。但当我尝试传回userInfo时,会出现“无法识别的选择器发送到实例”错误。所以我的ViewController中的选择器签名有问题,但我不知道是什么

以下是中断的代码:

在我的表格视图中

let data = ["selection": selectedOption]
dismissViewControllerAnimated(true, completion: {NSNotificationCenter.defaultCenter().postNotificationName(wordsetPickedNotification, object: self, userInfo: data)})
在我的视图控制器中:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "wordsetPicked", name: wordsetPickedNotification, object: nil)
...
func wordsetPicked(n:NSNotification) {
    //do stuff
}

选择器:“wordsetPicked”
更改为
选择器:“wordsetPicked:”

非常感谢您,这就像一个符咒……真不敢相信我因为冒号而被困在这上面一个多小时了@德里克亨特很高兴它成功了!如果这完全解决了您的问题,请单击我的答案左侧的复选框,以便其他用户知道您的问题已解决。以下是您为什么需要冒号的说明-