nsnotificationcenter

How To set Custom repeat interval For Nslocal Notification…?

房东的猫 提交于 2019-12-22 05:10:42
问题 i am New to iphone Development .I Am Trying To Use NslocalNotification In My Project I Need To Give Remeinder For Every 2Hours or For Every Two Days Or For Every Two Months Etc..Currently I am Using NslocalNotification Repeat Interval .But Its Working For Only Every Minute For Every Hour using Nscalender .... NSString *InterVal=[freQuencyArr objectAtIndex:index-2]; NSString *InterValType=[freQuencyArr objectAtIndex:index-1]; if(![InterVal isEqualToString:@"Every"]) { result=[InterVal intValue

KVO - How to get a list of an objects registered observers

心已入冬 提交于 2019-12-22 04:34:14
问题 I am registering an observer on a bunch of tableview controllers dynamically so I need to remove previous observers if they were registered on the same object. To do this I need to check if the observer exists on the object. Is this possible? I know with NSNotification you can use the NSNotification center singleton but is this the same for KVO? 回答1: No, there is no simple way that I'm aware of. KVO and NSNotification differs in that matter. Why don't you implement your solution with

watchkit , iOS sending data between watch and iphone

瘦欲@ 提交于 2019-12-22 01:27:59
问题 I want to create one button in watch and while tapping on watch start one process to my ios app. How can I send the data between 2 devices -(void)viewWillAppear:(BOOL)animated { [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(sayHello:) name: @"sayHelloNotification" object: nil]; } plus [[NSNotificationCenter defaultCenter] postNotificationName: @"sayHelloNotification" object: nil]; in my button watch but it doesn't work 回答1: AFAIK, you can not share data directly,

AVPlayer not finishing when streaming via AirPlay

▼魔方 西西 提交于 2019-12-21 20:00:18
问题 I am observing the following Notification to know when my HLS stream in AVPlayer has been played until the end: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didPlayToEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem]; This works fine when playing inside the app but when I stream via AirPlay, the notification is not sent. On my Apple TV it looks like the video has played up until shortly before the end of the video and then paused. So

Mac OS X - How to monitor a window change event?

Deadly 提交于 2019-12-21 17:06:03
问题 I'm developing a Cocoa application that shows a list of opened windows and highlights the current focused one. My problem is that I can't find a system notification to inform my app that the main (aka "focused" or "foreground") window has changed. I tried with: [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(wsNotificationHook:) name:NSWorkspaceDidActivateApplicationNotification object:nil]; but it monitors APPLICATION change: it isn't get fired when a

UIKeyboard Suggestions height for iOS 8 notification?

时光毁灭记忆、已成空白 提交于 2019-12-21 12:29:53
问题 I'm trying to keep a text field sitting atop the keyboard in iOS 8. But when a user swipes up or down the top of the keyboard to show or dismiss iOS 8 word suggestions, I need to a notification of the new height of the keyboard so I can move my text field up or down by that height. How can I accomplish this? Thanks! 回答1: You can register for UIKeyboardDidShowNotification and then get the keyboard frame from the notification with UIKeyboardFrameEndUserInfoKey. [[NSNotificationCenter

keyboard size given by NSNotificationCenter

老子叫甜甜 提交于 2019-12-21 04:37:14
问题 I want to add a accessoryView on a keyboard called from a UISearchBar. Since UISearchBar does not implement this property, I've just created a toolBar. Following Apple's documentation on the matter, I've decided to use notification center not only to know when the keyboard is called but also to know the size of the keyboard, which changes depending on the orientation. I've followed the example on the documentation and, on the keyboardWasShown method, I call an animation which will show the

Is removing a NotificationCenter observer that was created with closure syntax by name adequate?

你离开我真会死。 提交于 2019-12-21 03:53:14
问题 I have a few notifications that were created using block / trailing closure syntax which look like this: NotificationCenter.default.addObserver(forName: .NSManagedObjectContextObjectsDidChange, object: moc, queue: nil) { note in // implementation } Which I was later removing by name, like this: NotificationCenter.default.removeObserver(self, name: NSNotification.Name.NSManagedObjectContextObjectsDidChange, object: moc) My Question Is this adequate? Or do I absolutely need to save the

Is NSNotificationCenter thread safe?

不打扰是莪最后的温柔 提交于 2019-12-21 03:52:25
问题 Can I post a notification in a given queue and receive it on another? I want to use notifications to communicate different queues, but I'm not sure if this is safe... 回答1: No. Notifications are delivered in the same thread that they are sent from, this you will need to re-send it in some way to get the notification to your thread. 回答2: No. Apple's docs on the subject say: " Regular notification centers deliver notifications on the thread in which the notification was posted. [...] At times,

Are NSNotificationCenter events received synchronously or asynchronously?

大城市里の小女人 提交于 2019-12-20 11:48:10
问题 If a class registers for NSNotificationCenter events of a certain type and another class posts an event of that type, will the code in the receiver execute before (synchronously) or after (asynchronously) the posting class continues? - (void)poster { [[NSNotificationCenter defaultCenter] postNotificationWithName:@"myevent" object:nil]; NSLog(@"Hello from poster"); } - (void)receiver { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector:(mySelector) name:@"myevent" object