logo
  • 教程列表
  • SO官方文檔
  • NSNotificationCenter
    • 刪除觀察員
    • 新增觀察者
    • 使用資料釋出通知
    • 新增和刪​​除名稱的觀察者
    • 釋出通知
    • 觀察通知
    • 新增使用塊刪除觀察者
  1. StackOverflow 文件
  2. iOS 教程
  3. NSNotificationCenter
  4. 觀察通知

觀察通知

Created: November-22, 2018

迅速

func testNotification(notification: NSNotification) {
    let userInfo = notification.userInfo
    let myObject: MyObject = userInfo["someKey"]
}

Objective-C

- (void)testNotification:(NSNotification *)notification {
    NSDictionary *userInfo = notification.userInfo;
    MyObject *myObject = [userInfo objectForKey:@"someKey"];
}
  • 新增使用塊刪除觀察者
  • 釋出通知

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明