[問題] 關於不同程式間的NSNotificationCenter
大家好
想請問一下
如果我在a程式裡面使用
NSNotificationCenter *nc_in_a = [NSNotificationCenter defaultCenter];
在b程式裡面使用
NSNotificationCenter *nc_in_b = [NSNotificationCenter defaultCenter];
A與B的bundle id不同
想請教一下
假設
a程式的code有
[nc_in_a addObserver: ..... name:@"same_name" ...];
b程式的code有
[nc_in_b addObserver: ..... name:@"same_name" ...];
nc_in_a 與 nc_in_b
是否會互相干擾呢
觀念不是很清楚的部分還請各位指導
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.59.147.226
推
03/21 16:04, , 1F
03/21 16:04, 1F
→
03/21 16:05, , 2F
03/21 16:05, 2F
→
03/22 01:54, , 3F
03/22 01:54, 3F
→
03/22 12:03, , 4F
03/22 12:03, 4F
→
03/22 19:43, , 5F
03/22 19:43, 5F
→
03/24 14:26, , 6F
03/24 14:26, 6F
→
03/24 14:26, , 7F
03/24 14:26, 7F
→
03/24 14:27, , 8F
03/24 14:27, 8F
感謝大家回應
我改了一下問題
假設a裡面是
NSDistributedNotificationCenter* nc_in_a = [NSDistributedNotificationCenter
defaultCenter];
b裡面是
NSDistributedNotificationCenter* nc_in_b = [NSDistributedNotificationCenter
defaultCenter];
a程式的code有
[nc_in_a addObserver: ..... name:@"same_name" ...];
b程式的code有
[nc_in_b addObserver: ..... name:@"same_name" ...];
假設c程式
NSDistributedNotificationCenter* nc_in_c = [NSDistributedNotificationCenter
defaultCenter];
[nc_in_c postNotificationName:@"same_name" ..];
是不是a b 都會收到呢
看了說明是寫
Each task has a default distributed notification center that you access with
the defaultCenter class method. There may be different types of distributed
notification centers. Currently there is a single type—
NSLocalNotificationCenterType. This type of distributed notification center
handles notifications that can be sent between tasks on a single computer
我自己猜想這邊三個
nc_in_a
nc_in_b
nc_in_c
是同一個 會互相影響
(衍申的問題 想請教一下是否有辦法看到目前已經add的Observer)
還請大家指點
謝謝
※ 編輯: donkeychen 來自: 210.59.147.226 (03/24 14:40)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章