NSNotification *notification = [NSNotification notificationWithName:@"UserInfoNotify"
object:nil
userInfo:[NSDictionary dictionaryWithObjects:userInfoValues forKeys:userInfoKeys]];
發送訊息
[[NSNotificationCenter defaultCenter] postNotification:notification];
註冊觀察者
[[NSNotificationCenter defaultCenter] addObserverForName:@"UserInfoNotify"
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *notification) {
NSDictionary *dict = notification.userInfo;
}];
移除觀察者
[[NSNotificationCenter defaultCenter] removeObserver:self];
範例下載