在我的应用程序中,UITabBarController是storyBoard中的初始ViewController构建。我想在我的整个应用程序中观察数据更新。所以我在appDelegate中添加一个观察者......
AppDelegate.m
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shipCountBadge:) name:kShipCountBadge object:nil];
- (void)shipCountBadge:(NSNotification *)notification{
Groups *vc = [[Groups alloc] init];
[vc addBadgeCount:notification.object];
}
Group.m
- (void)addBadgeCount:(NSNumber *)count{
NSLog(@"d",[count intValue]);
[[self.tabBarController.tabBar.items objectAtIndex:2] setBadgeValue:[NSString stringWithFormat:@"%d",[count intValue]]];
}
它根本不会改变用户界面。我想知道如何在AppDelegate中更新UI实际上?任何人都有这个想法:)?