收到NSConcreteNotification,但没有定义?

Eim*_*tas 3 cocoa objective-c preferences

我正在为我的应用程序编写首选项,它会在登录时注册它(使用LSSharedItemListAPI).一切顺利,我的应用程序在复选框状态时切换其在用户的登录项中的存在.现在,当用户从"登录项目"中删除应用程序时,我想解决另一个问题Accounts.prefPane.

使用通知监视器我看到分布式通知中心发送com.apple.loginItemsListDidChnage(记住拼写错误)通知,因此我添加了该通知的观察者,其中相同的选择器(即IBAction)处理首选项窗口中的复选框(实际上,[un]从/注册应用程序登录项目).

当我尝试比较将我的应用切换为登录项的操作的发件人类时,会出现问题.使用[sender description]和[sender class]我看到NSConcreteNotification类,但是一旦我尝试对它进行比较 - 代码中断说没有定义这样的类:

if ([[sender class] isEqualTo:[NSConcreteNotification class]]) {
  ...
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试比较发送者NSNotification- 那么流量不会落入该分支.

也许我在Mac OS X中缺少关于分布式通知的一些基本知识?

运行Mac OS X 10.6.2

ken*_*ytm 14

NSConcreteNotification是抽象NSNotification类的私有子类.你不应该使用这NSConcreteNotification门课.如果要检查某个类是否为NSNotification,请使用-isKindOfClass::

if ([sender isKindOfClass:[NSNotification class]]) {
  ...
}
Run Code Online (Sandbox Code Playgroud)