- (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