NSDistributedNotificationCenter 通知失败?
我正在尝试在 NSDistribtedNotificationCenter 中发布通知,但在控制台中收到以下消息:
3/22/11 10:26:53 PM AIM[138] * 尝试发布分布式通知 (AIMIncomingMessages)忽略非字典 userInfo(或不是有效属性列表的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它的意思就是它所说的 - 当您使用 +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.