nsnotificationcenter

NSNotificationCenter - Way to wait for a notification to be posted without blocking main thread?

≯℡__Kan透↙ 提交于 2020-01-15 20:16:15
问题 I'm using an AFNetworking client object which makes an asynchronous request for an XML document and parses it. Also using NSNotificationCenter to post a notification when the document has finished parsing. Is there a way to wait for a notification to be posted without blocking the main thread? E.g code: -(void)saveConfiguration:(id)sender { TLHTTPClient *RESTClient = [TLHTTPClient sharedClient]; // Performs the asynchronous fetching....this works. [RESTClient fetchActiveUser:

AVPlayerItemDidPlayToEndTimeNotification not called

亡梦爱人 提交于 2020-01-15 12:57:50
问题 I have a video on a screen that must be played with an infinity loop. So I wrote : self.player = [AVPlayer playerWithPlayerItem:avItem]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[_player currentItem]]; [_player play]; And I fallback method is : - (void)playerItemDidReachEnd:(NSNotification *)notification { [_player.currentItem seekToTime:kCMTimeZero]; [_player play]; } It works well

AVPlayerItemDidPlayToEndTimeNotification not called

时光毁灭记忆、已成空白 提交于 2020-01-15 12:56:30
问题 I have a video on a screen that must be played with an infinity loop. So I wrote : self.player = [AVPlayer playerWithPlayerItem:avItem]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[_player currentItem]]; [_player play]; And I fallback method is : - (void)playerItemDidReachEnd:(NSNotification *)notification { [_player.currentItem seekToTime:kCMTimeZero]; [_player play]; } It works well

Can NSNotificationCenter be used between different apps to communicate?

故事扮演 提交于 2020-01-14 14:06:18
问题 An app can make internal use of NSNotificationCenter for different parts to communicate with each other, but can this be extended such that differing apps can use it to communicate? Edit : sorry for the confusion about iOS versus OSX. I only added the iOS tag, I don't know how/who/why an objective-c tag also got added, it wasn't me. 回答1: Sorry for a brief answer but in this case that's all there is to it - no they cannot. You can register to handle a URL type and then launch pass some data

Can NSNotificationCenter be used between different apps to communicate?

佐手、 提交于 2020-01-14 14:05:02
问题 An app can make internal use of NSNotificationCenter for different parts to communicate with each other, but can this be extended such that differing apps can use it to communicate? Edit : sorry for the confusion about iOS versus OSX. I only added the iOS tag, I don't know how/who/why an objective-c tag also got added, it wasn't me. 回答1: Sorry for a brief answer but in this case that's all there is to it - no they cannot. You can register to handle a URL type and then launch pass some data

Can NSNotificationCenter be used between different apps to communicate?

无人久伴 提交于 2020-01-14 14:02:06
问题 An app can make internal use of NSNotificationCenter for different parts to communicate with each other, but can this be extended such that differing apps can use it to communicate? Edit : sorry for the confusion about iOS versus OSX. I only added the iOS tag, I don't know how/who/why an objective-c tag also got added, it wasn't me. 回答1: Sorry for a brief answer but in this case that's all there is to it - no they cannot. You can register to handle a URL type and then launch pass some data

Notification Center vs. Delegation in iOS SDK

£可爱£侵袭症+ 提交于 2020-01-14 10:42:50
问题 Why did Apple choose to use delegation for some communication amongst SDK objects and to post notifications to Notification Center for others? In particular, I'm thinking about the set of keyboard appearance notifications that come from UIWindow. Is it because the Notification Center system means that more than one object can use the keyboard appearance action as a trigger to change its state, whereas only one object would have been able to act with a delegate implementation? 回答1: Delegation

Notification Center vs. Delegation in iOS SDK

喜你入骨 提交于 2020-01-14 10:42:40
问题 Why did Apple choose to use delegation for some communication amongst SDK objects and to post notifications to Notification Center for others? In particular, I'm thinking about the set of keyboard appearance notifications that come from UIWindow. Is it because the Notification Center system means that more than one object can use the keyboard appearance action as a trigger to change its state, whereas only one object would have been able to act with a delegate implementation? 回答1: Delegation

How to detect switch between macOS default & dark mode using Swift 3

眉间皱痕 提交于 2020-01-13 09:40:07
问题 I want to change my status bar app icon when the user switches from default to dark mode and vice versa (using Swift 3). Here’s what i have so far: func applicationDidFinishLaunching(_ aNotification: Notification) { DistributedNotificationCenter.default().addObserver(self, selector: #selector(darkModeChanged(sender:)), name: "AppleInterfaceThemeChangedNotification", object: nil) } ... func darkModeChanged(sender: NSNotification) { print("mode changed") } Unfortunately, it’s not working. What

Swift NSNotificationCenter?

跟風遠走 提交于 2020-01-11 12:43:56
问题 I'm trying to get the UITextViewTextDidChangeNotification to work. I'm new to using the NSNotificationCenter, so I'm having a hard time understanding what's going on exactly. I have a UITextView in a storyboard, and I've created an IBOutlet for it in my ViewController class and called it textView. This is my viewDidLoad function: override func viewDidLoad() { super.viewDidLoad() origin = self.view.frame.origin.y if let field = textView{ field.placeholder = placeholder field.layer.cornerRadius