【发布时间】:2015-07-20 09:28:51
【问题描述】:
我正在从一个类向另一个类发送通知,以使用
调用方法[[NSNotificationCenter defaultCenter]
postNotification:[
NSNotification notificationWithName:@"gestureIsOn"
object: self
]
];
我在这里想要实现的是在另一个类中接收通知,同时通过 UIGestureRecognizer 来查找它是哪个视图,因为接收通知的类包含 4 个不同的视图。我已经尝试实现这样的通知接收:
[[NSNotificationCenter defaultCenter ]addObserver:self
selector:@selector(handleGestures::) name:@"gestureIsOn"
object:nil];
并调用方法handleGestures:
-(void)handleGestures:(UIGestureRecognizer *)sender :(NSNotification *)notification{
if(sender.view == view1)
do something
}
尝试在我的观察者通知中使用双 :: 但这会导致错误 Terminating app due to uncaught exception 'NSInvalidArgumentException'
提前感谢所有花时间阅读本文的人。
【问题讨论】:
-
你能粘贴更多关于这个的日志吗?
-
我不能,因为我试图让问题保持简单并更改了我的类/变量名称以匹配问题
标签: ios objective-c notifications