I have a method in my app delegate that updates the badge count for the app’s icon. I want this method to also update something in another VC which is visible throughout the app (like a notification center) I have.
How can I do this?
The method looks like:
- (void) remedyERxInterface:(RSeRxInterface *)eRxInterface
didSynchronize:(BOOL)success pendingMessageCounts:(NSDictionary *)pendingMessageCounts {
NSInteger messageTotal = 0;
NSInteger refillRequests = [[pendingMessageCounts objectForKey:kRSQueuesRefillCount] intValue];
NSInteger problems = [[pendingMessageCounts objectForKey:kRSQueuesProblemCount] intValue];
NSInteger messages = [[pendingMessageCounts objectForKey:kRSQueuesMessageCount] intValue];
if (0) {
if (self.eRxModuleInboxMessageCount) {
messageTotal = refillRequests + problems + messages;
} else {
messageTotal = refillRequests + problems + messages + 12;
}
} else {
//Production
messageTotal = refillRequests + problems + messages;
}
[UIApplication sharedApplication].applicationIconBadgeNumber = messageTotal;
self.eRxModuleInboxMessageCount = messageTotal;
}
You mention a notification center. Have you looked into using NSNotifications through the NSNotificationCenter? It is ideal for a central entity to broadcast information without knowing who listens. You can just register your view controllers for these notifications with callbacks which will be called synchronously.