1. 程式人生 > >NSNotificationCenter以及app的幾種執行狀態

NSNotificationCenter以及app的幾種執行狀態

註冊通知:即要在什麼地方接受訊息

           [[NSNotificationCenter defaultCenter]  addObserver:self selector:@selector(mytest:) name:@" mytest" object:nil]

           [[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray];

   object:傳遞的引數

- (void) mytest:(NSNotification*) notification

{

   id obj = [notification object];//獲取到傳遞的物件

2~移除某個通知

    [[NSNotificationCenterdefaultCenter] removeObserver:selfname:UIKeyboardWillShowNotificationobject:nil];

3~APP幾種執行狀態