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
1 answer

NSNotication at time of day

I need my application to run method at a certain time of day, I think the best way would be to set up a notification for when it would get that time. I have used NSNoticationCenter before but I'm not sure how to set it up for a time of day. Edit: I…
Jonathan
  • 507
  • 5
  • 15
0
votes
1 answer

iOS reloadTable function from another view controller

I've two view controller A and B. Into A I have a UITableView and a NSNotification observer into viewDidLoad function. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshInterface) name:@"newDataAreAvailable"…
CeccoCQ
  • 3,746
  • 12
  • 50
  • 81
0
votes
2 answers

Prevent a weakly assigned variable from being dealloc'ed without creating a retain cycle

I have an odd case involving ARC, NSNotificationCenter and a block. The following is a simplified example of the code. From testing it seems that the memory management of didSaveObserver is performing as desired, i.e. it is not creating a retain…
0
votes
1 answer

NSNotificationCenter crash after changing UIViewController

I'm now implementing an application, whith iOS SDK 6.0, and i've got a problem. When i'm opening for the first time my UIViewcontroller where i implemented some NSNotificationCenter to detect when the user is clicking on the home button, it looks…
user2057209
  • 345
  • 1
  • 6
  • 19
0
votes
2 answers

How to check internet connectivity in ios?

How can I check whether the app is connected to the internet or not? currently, I am using this code in my appdelegate.m file dispatch_queue_t connectivityThread = dispatch_queue_create("com.gm.kart.connectivity",…
Naveen
  • 1,251
  • 9
  • 20
  • 38
0
votes
1 answer

Update current location in all views from navbar locationButton

I have a custom navbar with a locateButton that is visible in every view When a user taps the locateButton, I would like to update lat and long on every view. I've got it working in one view at a time, with the following code. ViewController.m -…
0
votes
1 answer

How does the NSNotificationCenter detect the deallocated observer in ARC?

I found that when using NSNotificationCenter in ARC, even you forget to remove the observer from defaultCenter, and the observer has deallocated, then you post the notification that the observer observed , there is no crash anymore !! before Xcode…
0
votes
2 answers

NSNotification not receiving in View Controller from appDelegate

hello i assign nsnotifiaction in app delegate.m's method and this method call eprox every 30sec, and i wants its notifcation in viewcontroller adn execute method, here is my code of appdelegate .m - (void)layoutAnimated:(BOOL)animated{ BOOL yy= …
0
votes
1 answer

nsnotification trouble

So I have a method: -(void)didLoginWithAccount(MyAccount *)account And I added an observer to this method like [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didLoginWithAccount:)]; And my question is, when I post…
Alick Dikan
  • 65
  • 2
  • 3
  • 10
0
votes
2 answers

How can I use NSNotificationCenter to call a method in a second class?

I'm trying to use NSNotificationCenter to call a method in a second class but I'm getting an error: second class method(request.m) : -(void)getTheRequest:(NSString *)whereToCall; and I'm trying to call it from NSNotificationCenter like…
HelenaM
  • 1,807
  • 6
  • 30
  • 41
0
votes
1 answer

UIViewcontroller not reloading after notification from observer

Hi I have a uiviewcontroller that adds 4 childviews after receiving data from a webservice. I add an observer to the uiviewcontroller that watches when the data is completely loaded from the webservice. Once it is, the uiviewcontroler adds 4…
0
votes
1 answer

postNotificationName si not being called?

Hello everyone postNotificationName is not being called in the following situation: I have a viewcontrollerA when i click on a button the user must login. So I do a presentmodal for the login. And just before presenting the modal I add the…
veereev
  • 2,650
  • 4
  • 27
  • 40
0
votes
2 answers

Forcing a delegate method to be called

I have a delegate method of an NSSplitView like this: - (void)splitViewWillResizeSubviews:(NSNotification *)aNotification { NSLog(@"RESIZE!"); } This method is called whenever I drag a divider, so it registered properly. I would like to call…
Carelinkz
  • 936
  • 8
  • 27
0
votes
1 answer

Debugging NSNotification crash that won't reproduce under XCode

My beta users are seeing the following crash on average once an hour: 0 libobjc.A.dylib 0x33182f78 objc_msgSend + 16 1 Foundation 0x3497e4f8 __57-[NSNotificationCenter…
Tim Kolar
  • 175
  • 1
  • 9
0
votes
1 answer

Problems with NSNotificationCenter and loading the UIViewControlletr

I have a UIViewController with button that brings another UIViewController. with clicking on button , as shown in my NSLog, and when this is done, I want to send a notification to load another viewcontroller . Well, although it seems everything is…
user1997934