我需要使用. NSMutableDictionary
_ 我已经尝试了以下代码,但它不起作用。我实际上传递给但没有调用该方法。有什么建议吗?谢谢!ViewControllerA
ViewControllerB
NSNotificationCenter
ViewControllerB
-receiveData
视图控制器A.m
- (IBAction)nextView:(id)sender {
[[NSNotificationCenter defaultCenter]
postNotificationName:@"PassData"
object:nil
userInfo:myMutableDictionary];
UIViewController *viewController =
[[UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:NULL] instantiateViewControllerWithIdentifier:@"viewcontrollerb"];
[self presentViewController:viewController animated:YES completion:nil];
}
视图控制器B.m
- (void)receiveData:(NSNotification *)notification {
NSLog(@"Data received: %@", [notification userInfo]);
}
- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(receiveData:)
name:@"PassData"
object:nil];
}