在兩個view之間傳遞參數方法之一
loginViewController.m
NSNotification *notification = [NSNotification notificationWithName:@"LoginNotify" object:nil userInfo:[NSDictionary dictionaryWithObject:account.text forKey:@"account"]];
[[NSNotificationQueue defaultQueue]
enqueueNotification:notification
postingStyle:NSPostWhenIdle
coalesceMask:NSNotificationCoalescingOnName
forModes:nil];
[activityView stopAnimating];
[self performSegueWithIdentifier:@"LoginSegue" sender:nil];
loginexeViewController.m
[[NSNotificationCenter defaultCenter] addObserverForName:@"LoginNotify" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification){
NSDictionary *dict = notification.userInfo;
NSLog(@"你的帳號:%@",[dict objectForKey:@"name"]);
}];
沒有留言:
張貼留言