Search code examples
iosnsnotificationcenter

How to combine multiple notifications of the same kind


I have an iOS app that shows the user a set of different news feeds in a PageViewController. Everytime the app starts, it requests the news data from the backend for every single feed. In case it worked fine, a notification via for every single news feed is sent via NSNotificationCenter so the data can be displayed. In case of an error, a notification for every single feed is sent as well, triggering a popup message that tells the user something went wrong. But if this happens, a popup will be shown for every news feed, up to the amount of added news feeds.

My question is, how can I combine all those error case notifications to a single one and therefore avoid having many useless and annyoing popups?


Solution

  • if (self.isShowingErrorDialog) {
        return;  // Or possibly cache to show after current one is dismissed.
    } else {
        [[UIAlertView ...] show];
        self.showingErrorDialog = YES;
    }