開發人員在開發過程中都會通過擴展點指定特定的系統功能,比如通知欄擴展、消息擴展、電話簿擴展等等都可以使用到,今天武林技術頻道小編搜羅整理了相關資訊,感興趣的網友們可別錯過那么好的機會哦!
// 發送通知- (void)postNotificaiton {CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();CFNotificationCenterPostNotification(notification, CFSTR("<notificaiton name>"), NULL,NULL, YES);} // 接收通知- (void)receiveNotification {CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter (); CFNotificationCenterAddObserver(notification, (__bridge const void *)(self), observerMethod,CFSTR("<notificaiton name>"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); }void observerMethod (CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo){ // Your custom work } // 移除通知- (void)removeNotification{CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();CFNotificationCenterRemoveObserver(notification, (__bridge const void *)(self), CFSTR("<notificaiton name>"), NULL);}以上內容給大家簡單介紹了教你如何在Host App 與 App Extension 之間發送通知,希望對大家有所幫助,同時也感謝大家繼續支持武林技術頻道!
新聞熱點
疑難解答