nsnotifications

keyboard height varies when appearing

自古美人都是妖i 提交于 2020-08-22 05:29:19
问题 I am trying to bring my views up when the keyboard appears by modifying the bottom constrain to the keyboard height. But the keyboard height returned to me is varying. When I tap on a textfield in the simulator, the keyboard height was 302 . When I try to toggle on and off the software keyboard, it shows 260 when the keyboard appears. Why is this happening? NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(FriendsViewController.keyboardWillShow(_:)), name:

How can I get notified of a system time change in my Cocoa application?

一个人想着一个人 提交于 2020-02-14 03:11:46
问题 I have a Cocoa application that records datestamps on events. I need to know when the system time is reset and by how much, but I can't seem to fine a notification anywhere that tells me such a thing has happened. This change could happen because NTP reset the clock or because the user reset (e.g. from System Preferences). It would be great if there was just a NSNotification I could register to receive, but I'm open to any suggestions. 回答1: Apple added in NSSystemClockDidChangeNotification,

How can I get notified of a system time change in my Cocoa application?

谁说我不能喝 提交于 2020-02-14 03:11:13
问题 I have a Cocoa application that records datestamps on events. I need to know when the system time is reset and by how much, but I can't seem to fine a notification anywhere that tells me such a thing has happened. This change could happen because NTP reset the clock or because the user reset (e.g. from System Preferences). It would be great if there was just a NSNotification I could register to receive, but I'm open to any suggestions. 回答1: Apple added in NSSystemClockDidChangeNotification,

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:

NSNotification when device time changes (minutes)?

被刻印的时光 ゝ 提交于 2020-01-14 02:10:10
问题 Is there a way I can easily set up a notification when the minutes change on the system time for iOS devices? I need to do some UI updates for time changes. I'd like the UI to update exactly on minute changes, not just every 60 seconds through an NSTimer trigger. 回答1: There are no notifications provided by the API but you could roll your own by having a background thread polling the system time and then sending a custom notification to the UI on the main thread. However, I wouldn't bother.

Class method and instance method with the same name in Objective-C

妖精的绣舞 提交于 2020-01-02 02:35:17
问题 I have a solution for a notification problem which works well, but I'm afraid might be a bad idea. I have a notification that needs to be handled by each instance of a class and by the class itself. To handle this, I'm registering for a notification by both the class and instances of the class. Because it's the exact same notification, I've named the class and instance method the same. This follows the standard we've set for how notification handlers are named. Is this a bad idea? Is there

application:didFinishLaunchingWithOptions: firing notification before destination controller is created

≯℡__Kan透↙ 提交于 2019-12-31 13:48:09
问题 Hello, I am writing an app that should respond with an UI update and an internal status change when a local notifcation is used to open it. I am using storyboards and I have set up my main view controller to observe status changes: - (void)viewDidLoad { [super viewDidLoad]; // ... [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resumeByNotification:) name:@"Resume" object:nil]; } In my app delegate I have this: - (void)application:(UIApplication *)application

application:didFinishLaunchingWithOptions: firing notification before destination controller is created

♀尐吖头ヾ 提交于 2019-12-31 13:45:09
问题 Hello, I am writing an app that should respond with an UI update and an internal status change when a local notifcation is used to open it. I am using storyboards and I have set up my main view controller to observe status changes: - (void)viewDidLoad { [super viewDidLoad]; // ... [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resumeByNotification:) name:@"Resume" object:nil]; } In my app delegate I have this: - (void)application:(UIApplication *)application

why do I get “wait_fences: failed to receive reply” for this code?

☆樱花仙子☆ 提交于 2019-12-30 11:29:30
问题 why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread? #import "ViewController.h" @implementation ViewController @synthesize alert; #pragma mark - Background Thread Test Methods - (void) ConfigTasksForBackground:(id)sender{ NSLog(@"ConfigTasksForBackground - Starting"); [NSThread sleepForTimeInterval:6]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self]; NSLog(@

why do I get “wait_fences: failed to receive reply” for this code?

China☆狼群 提交于 2019-12-30 11:27:07
问题 why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread? #import "ViewController.h" @implementation ViewController @synthesize alert; #pragma mark - Background Thread Test Methods - (void) ConfigTasksForBackground:(id)sender{ NSLog(@"ConfigTasksForBackground - Starting"); [NSThread sleepForTimeInterval:6]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self]; NSLog(@