3

我正在使用:

[[NSNotificationCenter defaultCenter] addObserver:self
                                      selector:@selector(stopTheDownload)
                                          name:UIApplicationDidEnterBackgroundNotification 
                                        object:nil];

每当用户将应用程序切换到其他应用程序时停止下载。但是多次调用通知会导致不良行为(多次取消相同的下载......)

这是正常的吗?我认为一旦有人单击主页按钮,通知只会发送一次。但现在情况并非如此,有时它会给出 6 UIApplicationDidEnterBackgroundNotification !(有时 2 次,有时 4 次,1 次……)

4

1 回答 1

4

您可能想查看何时添加观察者,以及是否删除了观察者。根据您实现观察者的方式,您可能会多次收到通知。

于 2011-07-28T22:27:34.710 回答