//通过通知获取值
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(getShopCarNumberAction:)name:@"getShopCarNumber"object:nil];
returnYES;
}
#pragma mark - 获取购物车的值
-(void)getShopCarNumberAction:(NSNotification *)noti
{
NSDictionary * dic = [notiuserInfo];
//self.numberLabel为在tabber上显示购物车数量的UILabel
self.numberLabel.text = [dicobjectForKey:@"shopCarNumber"];
}
#pragma mark - 加入购物车的点击按钮事件
-(void)buttonAction
{
[[NSNotificationCenter defaultCenter]postNotificationName:@"getShopCarNumber" object:nil userInfo:@{@"shopCarNumber":@"45"}];
}