postNotificationName是个同步调用

来源:互联网 发布:51单片机红外线遥控 编辑:程序博客网 时间:2024/04/29 23:16
- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    [self initData];    [self initView];        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reload) name:@"reload" object:nil];    [[NSNotificationCenter defaultCenter] postNotificationName:@"reload" object:nil];    NSLog(@"post 1");}static int i = 0;-(void)reload{    NSLog(@"call reloadData");    [_contactsTableView reloadData];    if(0 == i){        ++i;        [[NSNotificationCenter defaultCenter] postNotificationName:@"reload" object:nil];        NSLog(@"post 2");    }}

上面代码输出如下:


2015-03-24 13:44:43.099 MyContacts[2380:155259] call reloadData
2015-03-24 13:44:43.099 MyContacts[2380:155259] call reloadData
2015-03-24 13:44:43.099 MyContacts[2380:155259] post 2
2015-03-24 13:44:43.100 MyContacts[2380:155259] post 1

0 0
原创粉丝点击