nsnotifications

How to find out what UITextField caused a UIKeyboardWillShowNotification?

孤者浪人 提交于 2019-12-03 23:28:01
I am trying to use a customized keyboard in my application, but I am hitting problems when trying to restrict it to one particular UITextField. I based my code on this Xcode project (originally found on this blog ). That code adds a custom UIButton (representing a 'decimal point') into the UIKeyboardTypeNumberPad keyboard view. It does it by subscribing to UIKeyboardWillShowNotification and modifying the keyboard when it appears. That Xcode project works great, but when I add an extra UITextField, the custom key gets put into the keyboard for that text field too, even though I have selected a

Network Connection NSNotification for OSX?

落爺英雄遲暮 提交于 2019-12-03 21:34:49
I simply need to have a notification post when a valid IP address is assigned. I have tried polling via SCReachability, but that seems to be inefficient. Any suggestions? This seems like it should be simple, but I've been struggling for several hours to get anything working. I know this is a bit old but the selected answer is not ideal. The SCReachability API can be used to know when a particular host is reachable. If all you want to know is when a valid IP address is assigned (rather than a viable route to a target IP) then you should look at the SCDynamicStore* APIs instead. These functions

Best practices for passing data between processes in Cocoa

泪湿孤枕 提交于 2019-12-03 16:26:43
I am in the middle of solving a problem which requires me to do the following in my 64-bit Cocoa application: Spawn a 32-bit Cocoa helper tool (command line tool) from within my application. This helper will open a file (a quicktime movie to be precise) and access information about that file using 32-bit only APIs (Quicktime-C APIs) The data gathered from the 32-bit process needs to be passed back to the 64-bit application. The 64-bit app should wait until the 32-bit process completes before continuing There are many ways to accomplish this in Cocoa, but from what I gather these are two

NSNotification vs. dispatch_get_main_queue

夙愿已清 提交于 2019-12-03 12:25:27
问题 In relation to this question I was wondering if there is any generally accepted logic regarding when to use NSNotification, with an observer in your main thread, vs using GCD to dispatch work from a background thread to the main thread? It seems that with a notification-observer setup you have to remember to tear down the observer when your view unloads but then you reliably ignore the notification, where as dispatching a job to the main thread may result in a block being executed when the

NSUserDefaultsDidChangeNotification not sent when app resumes from the background

依然范特西╮ 提交于 2019-12-02 18:41:10
问题 Apple's documentation says that "the system queues many relevant notifications and delivers them to the app as soon as it starts executing code again (either in the foreground or background)", including NSUserDefaultsDidChangeNotification, but my app is not receiving it. Here's a log trace of relevant events: 2013-06-25 16:23:36.857 -[DPLAppDelegate applicationWillResignActive:] [debug]: end willResignActive 2013-06-25 16:23:36.859 -[DayViewController handlePreferenceChange:] [debug]: day

When to unsubscribe from a NSNotification in a UIView

元气小坏坏 提交于 2019-12-02 18:20:32
I am using the following NSNotifications within a UIView so that the view can be notified when a UIKeyboard appears and adjust its position (frame) on screen: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; The two notifications above are being subscribed to within the -init method of the UIView. Where is the best place to unsubscribe from these notifications once

View controllers sometimes do not receive an NSNotification

∥☆過路亽.° 提交于 2019-12-02 15:16:10
问题 So, I am just testing NSNotifications on a variety of cases and this one is confusing. I would appreciate it if you could help me understand NSNotifications ! I have a Navigation Controller. I have a UIBarButtonItem called "Add", which posts notification DidAddNotification If I click Add it pushes me to view2. // I add view2 as observer and write method for this and NSlog if it gets implemented // I again push myself to view 3. // I add view3 as another observer and use the same method as the

Present another View Controller from SkScene

亡梦爱人 提交于 2019-12-02 11:09:18
问题 I'm trying to present another viewController from my "SkScene". This is my main viewController (tuViewController) Code: -(void) openTweetSheet{ FacebookLikeViewDemoViewController *ctrl = [[FacebookLikeViewDemoViewController alloc] initWithNibName:@"FacebookLikeViewDemoViewController" bundle:nil]; [self presentViewController:ctrl animated:YES completion:nil]; } This is my "SkScene": tuViewController *viewController = [[tuViewController alloc]init]; [viewController openTweetSheet]; And the

View controllers sometimes do not receive an NSNotification

你离开我真会死。 提交于 2019-12-02 11:00:23
So, I am just testing NSNotifications on a variety of cases and this one is confusing. I would appreciate it if you could help me understand NSNotifications ! I have a Navigation Controller. I have a UIBarButtonItem called "Add", which posts notification DidAddNotification If I click Add it pushes me to view2. // I add view2 as observer and write method for this and NSlog if it gets implemented // I again push myself to view 3. // I add view3 as another observer and use the same method as the previous view and I NSlog if it gets implemented// From View 3, I popToRootViewControllerAnimated:YES

who is issuing my UIKeyboardDidHideNotification?

[亡魂溺海] 提交于 2019-12-02 10:49:57
问题 I want to register to UIKeyboardDidHideNotification that only my UIViewController is issuing. When I do : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:self]; I'm not getting any calls to keyboardDidHide: and when I do : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; I'm getting calls from all the other view