Skip to content

Instantly share code, notes, and snippets.

@gliubc
Last active November 22, 2019 01:37
Show Gist options
  • Save gliubc/1871dd497c44686db2f04e9af1c0f0ff to your computer and use it in GitHub Desktop.
Save gliubc/1871dd497c44686db2f04e9af1c0f0ff to your computer and use it in GitHub Desktop.
// 监听通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCartDataChangedNotification:) name:@"CartDataChangedNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveAlipayResultNotification:) name:@"AlipayResultNotification" object:nil];
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
/// 接收到购物车数据改变
- (void)receiveCartDataChangedNotification:(NSNotification *)notification {
self.cartDataChanged = YES;
}
- (void)receiveAlipayResultNotification:(NSNotification *)notification {
[self handleAlipayResult:notification.userInfo];
}
// 通知购物车数据已改变
[[NSNotificationCenter defaultCenter] postNotificationName:@"CartDataChangedNotification" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"AlipayResultNotification" object:self userInfo:resultDic];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment