求救!NSDistributedNotificationCenter在 Lion 底下不能工作啦!「已解決了」

Mac OS X 平台上程式設計的相關問題討論

版主: bryanchangdigdog謝孟叡

回覆文章
內容
發表人
頭像
rlong
嗜冰客
文章: 1530
註冊時間: 04/30/2001 1:01 am
來自: 新竹
聯繫:

求救!NSDistributedNotificationCenter在 Lion 底下不能工作啦!「已解決了」

#1 文章 rlong »

NSDistributedNotificationCenter 在 OSX10.6 以前都跑的好好的,
可以在同一部電腦的兩個應用程式間傳遞訊息,
但是到了 OSX7 Lion 卻不工作啦?

也就是說,在一個程式發出 NSDistributedNotification ,另一個程式卻收不到訊息,
請教高手,這要如何解決呀?

PS: 在 OSX10.6 及 OSX10.7 下,相同的兩個程式碼都用 XCODE 4.1 編譯執行。
最後由 rlong 於 07/26/2011 4:56 pm 編輯,總共編輯了 1 次。
I love OPERA !
頭像
rlong
嗜冰客
文章: 1530
註冊時間: 04/30/2001 1:01 am
來自: 新竹
聯繫:

Re: 求救!NSDistributedNotificationCenter在 Lion 底下不能工作啦!

#2 文章 rlong »

哈哈哈!

我自己找到解答了!

原來 Lion 為彌補前朝缺陷而做的補丁喔!

Distributed notification delivery

If you want a posted distributed notification to be received immediately, be sure you are passing the NSNotificationSuspensionBehaviorDeliverImmediately suspension behavior flag when registering for the notification, or using the NSNotificationDeliverImmediately flag when posting. Bugs in Mac OS X releases prior to 10.7 meant that sometimes a distributed notification would get delivered through to suspended observers, and not be properly queued, even when those flags weren't used.
I love OPERA !
回覆文章