您的位置:首页 > 其它

postNotificationName是个同步调用

2015-03-27 20:22 113 查看
- (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 reloadData2015-03-24 13:44:43.099 MyContacts[2380:155259] call reloadData2015-03-24 13:44:43.099 MyContacts[2380:155259] post 22015-03-24 13:44:43.100 MyContacts[2380:155259] post 1
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: