Questions tagged [nsnotification]

NSNotification is a class used to send messages to observing classes through NSNotificationCenter.

NSNotification is a class used to send messages to observing classes through NSNotificationCenter. Notifications must have a name and can be optionally associated with a specific object. If an object is provided, the notification is only delivered to a class that is also observing the exact same name and object.

To send a notification, use NSNotificationCenter's postNotification: (a convenience function postNotificationName:object:userInfo: also exists which creates a notification and posts it with a single call). Classes posting a notification can also include an optional userInfo parameter to pass an object to the receiving class.

For more information, see Apple's documentation for NSNotification and NSNotificationCenter.

312 questions
0
votes
0 answers

NSNotification Received But Method Is Not Called

I am posting notification from UIViewController object to UIView object. Notification is called but its method "playSound" is not called. Below is my code and Thanks in Advance : @interface SettingsViewController : UIViewController…
0
votes
3 answers

Converting seconds into hours, minutes, and seconds

I am making a stopwatch app. I am counting the time elapsed since the app was in the background, so that I can add it on to the stopwatch time when the app returns to the foreground. I have this code which is called when an NSNotification is sent to…
user2397282
  • 3,798
  • 15
  • 48
  • 94
0
votes
0 answers

Duplicate NSNotificationCenter observer when segueing to subclassed custom UIViewController

I have a custom UIViewController, called BoardViewController, and I have subclassed this to create GameBoardViewController. I added an NSNotificationCenter observer in viewDidLoad of BoardViewController. When I segue from another view controller to…
0
votes
1 answer

Problems receiving NSNotification when using popToRootViewControllerAnimated

I have a UIViewController where the user clicks a button and then they go onto another UIViewController to do some image manipulation. Once the image has been manipulated I want a NSNotification. My problem as it stands out is that I am not…
Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78
0
votes
2 answers

NSNotificationCenter previously working in iOS 6.1 - iOS 7 issue?

I have the following snippet of code in viewDidLoad which I post a notification to be received by a different ViewController, and prior to iOS 7 (and XCode 5) this has worked: if ([PFUser currentUser] && [PFFacebookUtils isLinkedWithUser:[PFUser…
daspianist
  • 5,336
  • 8
  • 50
  • 94
0
votes
1 answer

One NSNotification sent, but many selectors called

This is a strange accumulation bug that's somehow pushing my VCs onto the Nav VC multiple times. I have a UINavigationController with rootViewController set to CWLandingVC (lvc). - (BOOL)application:(UIApplication *)application…
roro
  • 265
  • 3
  • 11
0
votes
2 answers

Lifetime of the NSNotification object

Let's say I have this posting from one class that fires rapidly: [[NSNotificationCenter defaultCenter] postNotificationName:kGotData object:nil userInfo:someDictionaryObject]; And an observer from another class: [[NSNotificationCenter…
user523234
  • 14,323
  • 10
  • 62
  • 102
0
votes
1 answer

Force a NSWindow to stay active like a NSAlert

I would like to have a progress bar in a secondary window that stays active just like a NSAlert window. I especially like how it plays a sound when the user tries to click off of it. I figured out how to force the window to stay active by invoking:…
0
votes
4 answers

NSNotification - how to prevent unexpected crashes?

In my app I have a few VCs that need to receive NSNotifications from my model, which is fetching data asynchronously. The problem is that the VCs disappear from time to time and when the model finishes fetching data and tries to send a notification…
Nikolay Dyankov
  • 6,491
  • 11
  • 58
  • 79
0
votes
4 answers

Wrong value from NSNumber to enum

I'm sending a notification with enum inside: [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTitle object:nil userInfo:@{[NSNumber numberWithInt:option2]:kNotificationName}]; And receiving it: -…
Nat
  • 12,032
  • 9
  • 56
  • 103
0
votes
1 answer

CoreData: removal of 'didSave' notification immediately after save: call. Too soon?

-(void)someBackgroundTask { NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSConfinementConcurrencyType]; [context setPersistentStoreCoordinator:[self coordinator]]; // ... …
QED
  • 9,803
  • 7
  • 50
  • 87
0
votes
1 answer

UITableView using NSMutableArray to display dynamic content

Been looking for a solution for a long while now, but still no success, perhaps someone here can help me. I created an application that runs a thread that communicates with a webserver in the background. Occasionally the thread receives information…
Wolfgang Schreurs
  • 11,779
  • 7
  • 51
  • 92
0
votes
1 answer

App crash, no memory warning received

I have to read a very large file into memory (data processing while reading it is not an option, I have to have the entire file in the device memory). When the device runs out of memory, I should stop the reading and display an error message to the…
Levi
  • 7,313
  • 2
  • 32
  • 44
0
votes
2 answers

objective-c reload UITableView after back navigation

I have a TableViewController embedded in a NavigationController, at some point I use a Segue to push to a new ViewController. When I navigate back from the ViewController I want to reload the tableView in the TableViewController. I followed the…
jerik
  • 5,714
  • 8
  • 41
  • 80
0
votes
0 answers

NSMangedObjectNotification and save:

I'm using core data to persist my data model which is very simple, three entities like this: A<-->>B<-->>C. When something change in my model I need to perform some activity. To do so, I'm using listening to…