NSDistributedNotificationCenter 通知失败?

发布于 2024-10-26 14:47:21 字数 1100 浏览 4 评论 0原文

我正在尝试在 NSDistribtedNotificationCenter 中发布通知,但在控制台中收到以下消息:

3/22/11 10:26:53 PM AIM[138] * 尝试发布分布式通知 (AIMIncomingMessages)忽略非字典 use​​rInfo(或不是有效属性列表的 userInfo)。

这意味着什么?

编辑:这是代码:

[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"AIMIncomingMessages"
                                                               object:nil
                                                             userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                       @"Event Source", [NSNumber numberWithInt:3],
                                                                       @"Message:", [arg2 attributedString],
                                                                       @"Username:", [arg3 name],
                                                                       @"Timestamp:", [NSDate date],
                                                                       nil]
                                                   deliverImmediately: YES];

I am trying to post a notification in NSDistribtedNotificationCenter but I get these messages in console:

3/22/11 10:26:53 PM AIM[138] * Attempt to post a distributed notification (AIMIncomingMessages) with a non-dictionary userInfo (or one which is not a valid property list) ignored.

What does this mean?

EDIT: Here's the code:

[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"AIMIncomingMessages"
                                                               object:nil
                                                             userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                       @"Event Source", [NSNumber numberWithInt:3],
                                                                       @"Message:", [arg2 attributedString],
                                                                       @"Username:", [arg3 name],
                                                                       @"Timestamp:", [NSDate date],
                                                                       nil]
                                                   deliverImmediately: YES];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月光色 2024-11-02 14:47:21

它的意思就是它所说的 - 当您使用 +notificationWithName:object:userInfo: 创建通知时,您为第三个参数 (userInfo) 传递的内容不是字典或其他属性列表类型,因此通知将被忽略。如果您将用于创建问题通知的代码添加到您的问题中,我(或某人)可以为您提供更详细的建议,了解到底出了什么问题。

(编辑)好的,现在您已经添加了代码:创建字典时您已经向后列出了对象和键。它需要反过来,即值,键,值,键而不是键,值,键,值。

It means just what it says - When you created the notification with +notificationWithName:object:userInfo:, what you passed for the third argument (userInfo) wasn't a dictionary or other property list type, so the notification is being ignored. If you add the code you're using to create the notification to your question, I (or someone) can give you more detailed advice about exactly what's wrong with it.

(Edit) Okay, now that you've added the code: You've listed your objects and keys backwards when you create the dictionary. It needs to be the other way around, i.e. value, key, value, key instead of key, value, key, value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文