1

我有这个 if 语句检查我的委托是否实现了给定的方法:

    if ([[self delegate] respondsToSelector:@selector(didFinishSettingNotificationOnDialog:)])
{
        [self.delegate didFinishSettingNotificationOnDialog:self withNotification:notification];

}

但是我的代码没有在 If 语句中执行。我有其他委托调用在这些对象之间工作如果我删除 if 语句并调用

[self.delegate didFinishSettingNotificationOnDialog:self withNotification:notification];

它本身就可以工作!

我的代表确实正确实施:

- (void)didFinishSettingNotificationOnDialog:(NotificationDialogView *)dialogView withNotification:(NotificationContext *)setNotification{
    NSLog(@"Notification is: %@", setNotification);
}

那么我做错了什么?

4

1 回答 1

2

方法名称错误。应该是didFinishSettingNotificationOnDialog:withNotification:

尝试这个:

 if ([[self delegate] respondsToSelector:@selector(didFinishSettingNotificationOnDialog:withNotification:)]) {
    [self.delegate didFinishSettingNotificationOnDialog:self withNotification:notification];
}
于 2013-08-09T21:00:45.277 回答