nsnotificationcenter

kReachabilityChangedNotification is called multiple times

旧时模样 提交于 2019-12-10 03:14:15
问题 I'm using the Reachability classes for checking when I got an internet connection en when it goes down. This is my code: IN VIEW DID LOAD: internetReachable = [Reachability reachabilityForInternetConnection]; [internetReachable startNotifier]; // check if a pathway to a random host exists hostReachable = [Reachability reachabilityWithHostname:@"www.google.com"]; [hostReachable startNotifier]; Then the notification method -(void) checkNetworkStatus:(NSNotification *)notice { // called after

Why does EAAccessoryDidConnectNotification occur twice?

吃可爱长大的小学妹 提交于 2019-12-09 17:15:51
问题 I have a class that manages messages coming from and going to an external accessory to an iPad. In the init I have the following code: - (id) init { self = [super init]; if (!self) return; [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications]; //we want to hear about accessories connecting and disconnecting [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil]; [

View controller dealloc not called when using NSNotificationCenter code block method with ARC

隐身守侯 提交于 2019-12-09 17:00:51
问题 When I use -addObserverForName: object: queue: usingBlock: for NSNotificationCenter in the -viewDidLoad: method of my view controller, the -dealloc method ends up not being called. (When I remove -addObserverForName: object: queue: usingBlock: , -dealloc is called again.) Using -addObserver: selector: name: object: doesn't seem to have this problem. What am I doing wrong? (My project is using ARC.) Below is an example of my implementation, in case I'm doing something wrong here: [

NSNotification postNotificationName in AppDelegate but NSNotificationCenter in ViewController?

允我心安 提交于 2019-12-09 01:36:14
问题 I can't get the selector method, receiveChatText, in the NSNotificationCenter to execute and I am wondering if the problem is because the NSNotification postNotificationName is in AppDelegate.m but NSNotificationCenter is in ViewController.m? I.E. can the postNotificationName know that the NSNotificationCenter is in another viewController file or is that something I need to tell it? In a viewController.m I have -(id)init { self = [super init]; if(self){ [[NSNotificationCenter defaultCenter]

How Application will get to know Availability of internet connection in iPhone?

孤街醉人 提交于 2019-12-08 14:21:51
问题 I am new to Iphone app development so i am having some couple of questions. Help me out on this. 1) How, all the application on iphone will get to know that, there is internet connection available when user switches on wifi button or Cellular button in settings? 2) How to differentiated between wifi connection and cellular connection? 3) Are there any Broadcast receiver mechanism in iphone similar to android concepts as well? I had googled many links for internet connectivity, and got to know

NotificationCenter swift3 Can't observe post

馋奶兔 提交于 2019-12-08 10:19:56
问题 I have 3 notifications: NotificationCenter.default.post(name:NSNotification.Name("Notification1"), object: nil) NotificationCenter.default.post(name:NSNotification.Name("Notification2"), object: nil) NotificationCenter.default.post(name:NSNotification.Name("Notification3"), object: nil) And I have for each post one differents observer in view controller First : NotificationCenter.default.addObserver(forName:NSNotification.Name("Notification1"), object: nil, queue: nil, using: updateUx) Second

NSNotificationCenter: addObserver that is not self

余生颓废 提交于 2019-12-08 05:37:27
Here's the question: Can one View Controller add another View Controller as an Observer to the defaultCenter before the second view has been loaded? I have a model class that creates a NSURLSession , grabs some data, builds an array, and sends notifications that it's done (along with a pointer to the array). My app loads with a Map View that instantiates the model, calls the method to create the array, listens for the notification, and drops pins using the array. I have a Table View tab that I want to load using the array built by the map. Can my Map View add my Table View Controller as an

NSNotificationCenter: addObserver that is not self

99封情书 提交于 2019-12-08 03:26:12
问题 Here's the question: Can one View Controller add another View Controller as an Observer to the defaultCenter before the second view has been loaded? I have a model class that creates a NSURLSession , grabs some data, builds an array, and sends notifications that it's done (along with a pointer to the array). My app loads with a Map View that instantiates the model, calls the method to create the array, listens for the notification, and drops pins using the array. I have a Table View tab that

Repeat Daily Local Notifications in iOS 10 does not get triggered when manually setting the Time and Date?

和自甴很熟 提交于 2019-12-07 12:35:29
问题 I'm trying to test local notifications in iOS 10 by trying to trigger a daily notification. I am using the following sample project: NotificationsUI-Demo In the app is one of the following code: let calendar = Calendar(identifier: .gregorian) let components = calendar.dateComponents(in: .current, from: date) let newComponents = DateComponents(calendar: calendar, timeZone: .current, month: components.month, day: components.day, hour: components.hour, minute: components.minute) let trigger =

Is there a notification on iOS if a UIAlertView is shown?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 03:35:45
问题 Wondering if there is a notification available if a UIAlertView pops up? Background: my app asks the user for a PIN after a period of inactivity but I would like to prevent it if an alert is on screen. I don't want to go through my code and find all alerts and disable the PIN checker, instead a notification would be awesome. Any hope with NSNotification ? 回答1: Just found the answer. It is hidden in here: Can I get message when I show UIAlertView If you listen to the "