nsnotificationcenter

Observing changes in the properties of an NSManagedObject: how to avoid looping?

微笑、不失礼 提交于 2020-01-05 10:14:49
问题 In my application, I observe the properties of a managed object. A change may lead to adjustments in some of its other properties, so the managed object itself receives a message of a changed property. These changes happen through bindings that are set up in the Interface Builder. I have the following method in the implementation of the managed object: -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (

Observing changes in the properties of an NSManagedObject: how to avoid looping?

夙愿已清 提交于 2020-01-05 10:14:07
问题 In my application, I observe the properties of a managed object. A change may lead to adjustments in some of its other properties, so the managed object itself receives a message of a changed property. These changes happen through bindings that are set up in the Interface Builder. I have the following method in the implementation of the managed object: -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (

Using NotificationCenter Observer to Handle Asynchronous Requests

余生颓废 提交于 2020-01-05 09:07:37
问题 Similar questions to this have been asked so I apologize, but none of them have been able to help me. I am struggling to return the value from this asynchronous request to Firebase with a completion handler. The value I am retrieving from Firebase is an array and it does exist. But Here is my function for making the request to Firebase: class SearchManager { var searchResults = [String]() var listOfMosaics = [String]() // Retrieves company list from Firebase func getMosaicTitles

MPMusicPlayerController does not send background notifications when using Apple Music (Sample Project is Included)

允我心安 提交于 2020-01-05 04:06:17
问题 This is a problem that has been bothering us for months now. I created a bug report for apple, but they aren't responding. I also created a sample project that demonstrates the bug. I would really appreciate any ideas that you guys have. So without further adieu, here is the description of the problem and a link to the sample project. Thank you so much! Sample Project: https://dl.dropboxusercontent.com/u/28210/AppleMusicBug.zip MPMusicPlayerController is used to play Apple Music songs via the

Is there a NSNotificationCenter Notification for WiFi network changes?

妖精的绣舞 提交于 2020-01-04 04:07:08
问题 I'd like to subscribe to WiFi network changes in my Cocoa application, but I haven't been able to find an appropriate event to subscribe to. Is there an NSNotificationCenter Notification for WiFi network changes? 回答1: Not to my knowledge. I would use CoreWLAN to get a list of all WiFi interfaces on the system, and then monitor their status using the SystemConfiguration framework. Here's a command-line example (error checking niceties elided, ARC required): #import <Foundation/Foundation.h>

Waiting for UITextView to Finish Updating Text (iOS 7.1)

佐手、 提交于 2020-01-03 04:32:21
问题 I'm programatically updating the attributedText of a UITextView . Following the update I want to call setContentOffset so that I can scroll to position the new text. The problem I'm having is that there's a delay in the text view updating its text. With the following code the debug log outputs the same value: - (void)appendToTextView:(NSString*)text { CGFloat bottomOfCurrentContent = _pastedText.contentSize.height; NSLog(@"Bottom of content, before = %f", bottomOfCurrentContent); NSString*

iOS - NSNotificationCenter multiple UIKeyboard notification

北城余情 提交于 2020-01-02 13:50:15
问题 I have two view controllers let's call them A and B (1) in A I show a popOver containing a textField (2) in B there is an UITextView used for simple text editing I Have to manage the keyboard in A and in B to scroll the content hidden by the keyboard. I know how to reposition the content. What I need is a way to have different behavior on the same notifications types that in my are UIKeyboardWill(Show/Hide)Notification. What I've done so far : (1) I've added this code in each controller [

Swift 2 addObserver for specific textField with the object parameter

落爺英雄遲暮 提交于 2020-01-02 06:38:26
问题 To my understanding the object parameter of the addObserver method is the object you want to receive notifications from. Most of the time I see it as nil (I assume this is because notifications of the specified type are wanted from all objects). In my particular case I have a text field at the top of the screen and at the bottom of the screen and I want the view to move up only when the user taps the bottom text field, not the top one. So I call the following method in viewWillAppear func

Cannot receive NSWorkspaceDidWakeNotification in swift OSX

梦想的初衷 提交于 2020-01-02 04:37:08
问题 I'm making a mac application where it's necessary to do something when the computer wakes falls asleep and wakes up, but I can't get the listener to work. I feel like I've tried everything. In AppDelegate.swift, inside of the function applicationDidFinishLaunching, I've got: NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, selector: "sleepListener", name: NSWorkspaceWillSleepNotification, object: nil) NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self,

Main Thread Runloop gets blocked on opening nsmenu

筅森魡賤 提交于 2019-12-31 01:41:27
问题 I have an application for which the UI element includes an NSStatusItem and a menu. Inside my application , I am using NSTask asynchronously to perform some operation and I am using the output obtained using the NSFileHandleReadCompletionNotification to update the menu. But now whenever I click and open the menu , the main runloop goes into NSEventTrackingRunLoopMode and the notification posting fails. So basically with my menu open , no operation takes place on the main thread. Now I found a