NSNumber *theTag = [NSNumber numberWithInt:btn.tag];
NSDictionary *tagInfo = [NSDictionary dictionaryWithObject:theTag forKey:@"theTag"];
// 设置通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"setView" object:nil userInfo:tagInfo];
// 接收通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(choosenBtn:) name:@"setView" object:nil];
/**
* 通知触发方法
*/
- (void)choosenBtn: (NSNotification*) aNotification
{
MLTabBarButton *btn = [[MLTabBarButton alloc] init];
NSDictionary *tagInfo = aNotification.userInfo;
NSString *a = [tagInfo objectForKey:@"theTag"];
// 字符串转integer
btn.tag = [a integerValue];
[self btnOnClick:btn];
[self setSelectIndex:btn.tag];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"setView" object:nil];
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。