0
我有一個窗口的UIAgent
應用程序。我想從另一個應用程序中隱藏/顯示它。如何用可可粉做它?看起來像hide
/unhide
NSRunningApplication
的方法不會影響UIAgent進程。如何用可可隱藏UIAgent進程的窗口
在此先感謝
我有一個窗口的UIAgent
應用程序。我想從另一個應用程序中隱藏/顯示它。如何用可可粉做它?看起來像hide
/unhide
NSRunningApplication
的方法不會影響UIAgent進程。如何用可可隱藏UIAgent進程的窗口
在此先感謝
我NSDistributionNotifications
解決它。在UIAgent應用程序,我添加一個觀察者的@"QuitProcessNotification"
(任何其他名稱):
[[NSDistributedNotificationCenter defaultCenter]
addObserver:self selector:@selector(quit:)
name:@"QuitProcessNotification"
object:@"com.MyCompany.MyApp"
suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
回調看起來像這樣:
- (void) quit:(NSNotification *) notification
{
[NSApp terminate:nil];
}
在主要應用: 發送通知:
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"QuitProcessNotification"
object:@"com.MyCompany.MyApp"
userInfo: nil /* no dictionary */
deliverImmediately: YES];
請確定,object
參數確實是您的發件人應用程序的包標識符。