nsnotificationcenter

Xcode debugger (lldb) get object description from memory address

喜你入骨 提交于 2019-12-18 07:12:54
问题 Little-known fact: It is now possible, in Xcode, while paused in the debugger, to introspect the notification center to learn what objects are registered to receive what notifications: (lldb) po NotificationCenter.default <NSNotificationCenter:0x6040000d40b0> Name, Object, Observer, Options com.apple.accessibility.reduce.motion.status, 0x10b126190, 0x7fc795700140, 1001 com.apple.accessibility.asst.scanner.status, 0x10b126190, 0x7fc795700140, 1001 // ... etc. ... Very nice, but how do I get

Swift iOS -AVPlayer Video Freezes / Pauses When App Comes Back from Background

怎甘沉沦 提交于 2019-12-18 06:19:10
问题 I have a video playing in a loop on the login page of my app. I followed this Youtube tutorial to get it to work loop video in view controller The problem is when the app goes to the background, if I don't come back right away, when i do come back the video gets frozen. According to the Apple Docs that's supposed to happen. I tried to use the NotificationCenter's Notification.Name.UIApplicationWillResignActive but that didn't work. How do I get the video to keep playing once the app returns

why do you have to remove observer in ios8?

妖精的绣舞 提交于 2019-12-18 04:17:21
问题 After reading this post for iOS 9, I know that you don't need to removeObserver anymore. However for iOS 8, you needed to removeObserver in the deinit method of the viewController. But I can't make sense of it. If a viewController is deallocated then it's DEAD isn't? Why do we need to do a removeObserver. It being an observer is much like calling a dead person who will never pick up the phone What am I not understanding? 回答1: It's fully explained in the article you linked: The notification

NSUserDefaultsDidChangeNotification: What's the name Of the Key, that Changed?

余生长醉 提交于 2019-12-18 02:57:18
问题 This code will call the method "defaultsChanged", when some value in UserDefaults changed NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(defaultsChanged:) name:NSUserDefaultsDidChangeNotification object:nil]; This Code will give me the VALUE that changed - (void)defaultsChanged:(NSNotification *)notification { // Get the user defaults NSUserDefaults *defaults = (NSUserDefaults *)[notification object]; // Do something with it

NSOperation and NSNotificationCenter on the main thread

社会主义新天地 提交于 2019-12-17 23:29:27
问题 I have an NSOperation. When it is finished I fire a NSNotificationCenter to let the program know that the NSoperation is finished and to update the gui. To my understanding listeners to the NSNotification will not run on the main thread because the NSOperation is not on the main thread. How can I make it so that the listeners run on the main thread when I fire my event? [[NSNotificationCenter defaultCenter] postNotificationName:@"myEventName" object:self]; 回答1: You can use

thumbnailImageAtTime: now deprecated - What's the alternative?

十年热恋 提交于 2019-12-17 15:34:46
问题 Until iOS7 update I was using... UIImage *image = [moviePlayer thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame]; ...with great success, so that my app could show a still of the video that the user had just taken. I understand this method, as of iOS7 has now deprecated and I need an alternative. I see there's a method of - (void)requestThumbnailImagesAtTimes:(NSArray *)playbackTimes timeOption:(MPMovieTimeOption)option though how do I return the image from it so I can

How can I listen for all notifications sent to the iOS NSNotificationCenter's defaultCenter?

最后都变了- 提交于 2019-12-17 15:15:55
问题 I want to listen to all notifications dispatched to the defaultCenter. Both public and private. Does anyone know how I can do this? 回答1: Use NSNotificationCenter's addObserverForName:object:queue:usingBlock: OR addObserver:selector:name:object: method and pass nil for the name and object. Example The following code should do the job: - (void)dumpNotifications { NSNotificationCenter *notifyCenter = [NSNotificationCenter defaultCenter]; [notifyCenter addObserverForName:nil object:nil queue:nil

OSX Notification Center Icon

末鹿安然 提交于 2019-12-17 10:44:51
问题 I'm using OSX's Notification Center APIs for the first time and can't seem to figure out how to make my app's icon to show up in the Notification badge. The default "your app doesn't have an icon" icon keeps showing up: Here's what I've done so far I have created an icns file that includes 512, 256, 128, 32 & 16px versions dragged the icon into the "App Icon" section of the target's summary I made to sure to check the box to copy the icon into the project the plist's "Icon file" section

Type 'NSNotification.Name' has no member 'keyboardDidShowNotification'

落花浮王杯 提交于 2019-12-17 09:45:17
问题 I'm getting this error with Swift 4.2 Type 'NSNotification.Name' has no member 'keyboardDidShowNotification' Here is my code: NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.keyboardDidShowNotification, object: nil) Following one was working fine with Swift 4 but not with Swift 4.2 NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name

Type 'NSNotification.Name' has no member 'keyboardDidShowNotification'

孤者浪人 提交于 2019-12-17 09:45:16
问题 I'm getting this error with Swift 4.2 Type 'NSNotification.Name' has no member 'keyboardDidShowNotification' Here is my code: NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.keyboardDidShowNotification, object: nil) Following one was working fine with Swift 4 but not with Swift 4.2 NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name