NSNotificationCenter带参
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NSNotificationCenter带参相关的知识,希望对你有一定的参考价值。
(1)post Notification类
[[NSNotificationCenter defaultCenter] postNotificationName:CRMPerformanceNewCellCurrentPageShouldChange object:@(performanceTabConfigure.tab)];
(2) Notification的观察者类
//.h文件 extern NSString *const CRMPerformanceNewCellCurrentPageShouldChange; //.m文件 NSString *const CRMPerformanceNewCellCurrentPageShouldChange = @"CRMPerformanceNewCellCurrentPageShouldChange"; //addObserver [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(currentPageShouldChange:) name:CRMPerformanceNewCellCurrentPageShouldChange object:nil]; // 执行函数 - (void)currentPageShouldChange:(NSNotification*)aNotification { NSNumber *number = [aNotification object]; self.pageControl.currentPage = [number integerValue]; }
以上是关于NSNotificationCenter带参的主要内容,如果未能解决你的问题,请参考以下文章
NSnotificationCenter 正确使用姿势, removeObject 探索