Questions tagged [nsnotificationcenter]

NSNotificationCenter allows to send and register for notifications in the Foundation framework, which is provided by Apple.

An NSNotificationCenter object (or simply, notification center) provides a mechanism for broadcasting information within a program. An NSNotificationCenter object is essentially a notification dispatch table. Notifications are differentiated according to their name and contain an object (the sender) as well as any specific data.

Objects register with a notification center to receive notifications (NSNotification objects) using the addObserver:selector:name:object: or addObserverForName:object:queue:usingBlock: methods. Each invocation of this method specifies a set of notifications. Therefore, objects may register as observers of different notification sets by calling these methods several times.

You can also post notifications with postNotification:, or create and post notifications with postNotificationName:object: and postNotificationName:object:userInfo:, where you may use custom names for your notifications.

References:

1577 questions
0
votes
2 answers

iOS - Call delegate method on main view from popover inner (pushed) view?

I need to call a delegate method on my main view controller ('showDetails:') from a popover view's pushed view (embedded in navigation controller). This is all from a storyboard setup. The hierarchy is: Main view -> Popover (menu tableview embedded…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
0
votes
1 answer

Reachability crashes every time network changes status

My app crashes every time the network status changes from no network to network or vice versa at the following line with EXC_BAD_ACCESS: dispatch_async(dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter]…
Matt
  • 2,920
  • 6
  • 23
  • 33
0
votes
1 answer

addObserver: name

I'm using an addObserver like so: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(notificationReceived:) name:nil object: nil]; Everything works well, but I thought it might be good form to remove the observer when I no…
RanLearns
  • 4,086
  • 5
  • 44
  • 81
0
votes
2 answers

How to launch app automatically on alarm notification?

I am developing an app which has a feature to set an alarm and on alarm time local notification will be fired. is it possible to open an application on local notification event without having a user interaction?
user4003752
0
votes
4 answers

Best way to send a message to multiple children view controllers

I implemented a custom UIViewController which has multiple child view controllers (mainly by using the storyboard's Container View but not only). I'm wondering what is the best way for the "root" view controller to send a message to its children,…
0
votes
2 answers

One Cocoa app notified when another cocoa app terminated

Suppose there are two cocoa apps APP1 and APP2. I want APP2 to be notified when APP1 terminates. I want some callback function registered with APP2 which will be called as soon as APP1 terminates. How can I achieve this? Any sample code will be…
0
votes
2 answers

UIView not returning to proper position after animation

I have a simple UITextField, that when someone goes to edit it, and the keyboard pops up, the view shifts up so that the user can see what they are entering. However, when I close the keyboard, the view is not returning to the original position! I…
Jon Erickson
  • 1,876
  • 4
  • 30
  • 73
0
votes
1 answer

One notification posted multiple times (one Observer)

Is it ok to send one notification (by one I mean the same postNotificationName: postNotificationName:@"notification_name") in multiple classes? Observer is the AppDelegate.m and it is sharing NSDictionary. Before every class send Notification it is…
lvp
  • 2,078
  • 18
  • 24
0
votes
2 answers

show loading overlay while performing a selector on the main thread after notification

I am working on an IPhone application. I am doing an asynchronous update from the server. When the update finishes downloading, I issue a NSNotification [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_DATA_RECEIVED…
Y2theZ
  • 10,162
  • 38
  • 131
  • 200
0
votes
1 answer

No code executed inside NSNotification handler method even the method is called properly

I've strange problem. In ViewController.m, I post notification after successful save and perform Segue to ListViewController. In ListViewController.m, I set up observer in viewDidLoad and declare method for handling. The problem is that handler…
alexhajdu
  • 410
  • 5
  • 13
0
votes
0 answers

(UIApplicationDidBecomeActiveNotification) Is not being called until the cocos2d frame interval goes from 15 down to 1?

I am trying to display UIAlert view when my application gets opened from running in the background, but the notification is not getting called until the cocos2d frame interval has dropped from 15 down to 1. I don't understand what this means. Could…
0
votes
2 answers

NSNotification to TableViewController not working

I have a tabbar controller with 2 tabs - A and B. Tab A is a regular UIViewController and tab B is a TableViewController. I am trying to post a NSNotification from tab A and receive the the same and display the data in the table in tab B. I post the…
0
votes
0 answers

How to send data with NSNotificationCenter and reload a UITable after the data is received?

I have a NSNotification in viewController1 that sends the object:selectedTableString when the didSelectRowAtIndexPath: method is called in viewController1. The object:selectedTableString object is then picked up in viewController2. The console…
hanumanDev
  • 6,592
  • 11
  • 82
  • 146
0
votes
1 answer

Trying to call multiple viewControllers one at a time via NSNotifications in iOS

I have an application that I am working on that has several viewControllers, with each one displaying a single test for the user to do. At the moment, the user is able to go through each one individually. However, I am trying to implement a…
syedfa
  • 2,801
  • 1
  • 41
  • 74
0
votes
1 answer

Pushing view controller from app delegate

So recently I had to reorganize my tab bar and remove one the tabs for a view controller that I still need to access at the end of the app. I am using NSNotifications which triggers a method in the app delegate which basically switches the tab…