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

comparing NSUpdatedObjectsKey to NSString I get error: -[__NSSetI isEqualToString:]: unrecognized selector sent to instance

I'm trying to compare the string changes in core data. I add observer to NSArrayController and it working fine the problem is when I try to compare the string changes. Here is my code: - (void)mocDidChangeNotification:(NSNotification…
user2924482
  • 8,380
  • 23
  • 89
  • 173
0
votes
2 answers

Passing extra data to NSTask output handler

I need to read the output of an NSTask. The code from this post achieves this:How to receive output of NSTask in Cocoa?. However, I want to pass in additional data to this function. I tried to create a dictionary and pass that in through the…
Nate
  • 510
  • 1
  • 4
  • 21
0
votes
1 answer

Adding NSNotification Observer using swift

I was using this example which explains the use of NSNotification. In my case, I have a UIViewController in which I have a UITableView. To this tableview I am assigning a dataSource and delegate programatically by instatiating my…
rgamber
  • 5,749
  • 10
  • 55
  • 99
0
votes
1 answer

iOS keyboardWasShown, NSNotification and Optional issue

Sometimes I feel so lost in the world of iOS code. It's telling me it's not unwrapped it should have a "!". When I fix it, it's telling me it's wrong and to delete the "!". So I keep going in a loop. I can't for the life of me figure out what is…
Lavvo
  • 1,024
  • 3
  • 16
  • 35
0
votes
1 answer

Swift NSDate Comparison

I need to schedule a notification. If the date made from the current date date components with the dateFromData time components is early than the current day, I would like to change it to the next day. Here is what I have so far. The date…
0
votes
0 answers

Update UI of app upon launch from URL scheme using notifications

I've implemented a Notification Center Extension that provides a button to launch its containing app. Depending on the state of the widget I want to navigate to one of two different locations in the app when this button is pressed. I was able to…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
0
votes
1 answer

UIApplicationDidEnterBackgroundNotification delivered after entering foreground

I register my VC for UIApplicationDidEnterBackgroundNotification [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackgroundNotification:) name:UIApplicationDidEnterBackgroundNotification…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
0
votes
2 answers

iOS - How to reference Keyboard Notification outside of method?

I currently register for keyboardWillBeHidden and keyboardFrameDidChange methods to change the ScrollView size when the keyboard is open. In my textViewDidChange, I have a little text to make sure that cursor is in the view: if ([textView.text…
Eichhörnchen
  • 592
  • 2
  • 12
  • 27
0
votes
1 answer

NSNotificationCenter selector method is not called

Hi i am trying to use NSNotification center in my application.The selector method is not being called from the code.I found similar questions in this site like this, but still i am unable to resolve the error. i am posting notification in…
srinivas
  • 109
  • 1
  • 3
  • 14
0
votes
2 answers

iOS UITableView behaviour broken when not active

My current set up is the following: Root Tab Bar: Collection view with magazines Bookmarks (with a table view) Others You can add a bookmark from a magazine in the collection view and also remove it from there. The behaviour I'm seeing is the…
0
votes
1 answer

Notification not being recognised

I am trying to post a notification without much success! I can do it ok for the keyboard without issue but now am trying a custom one as follows: In my rootview I have this .h -(void) allowEdits:(NSNotification *)notification; .m //this section is…
user7865437
  • 812
  • 14
  • 28
0
votes
2 answers

Adding NSNotification cause app crash

I have two classes one is base class and the other is subclass. In the base class i am adding a notification that will be fired when the app goes to the background. But some how the app crashes after executing the handleAppBackground method. I guess…
0
votes
2 answers

How to send a string along with NSNotification?

I'm trying to write a plugin for phonegap/cordova that allows audio to resume when interrupted by a phone call. I'm using AVAudioSesionInterruptionNotification and it is working well. However, I need to be able to send a string to my event handler,…
0
votes
2 answers

Is there any way to find out where iOS app is downloaded, however never launched?

Is there any way to find out where iOS app is downloaded, however never launched? I am trying following things for that - 1. Send a notification, and on Didreceivenotification handler try to figure out how many didnt click on the notification / iOS…
Snehal Patil
  • 93
  • 3
  • 10
0
votes
2 answers

Handle NSNotification while scrolling a inner UITableView

I need some UIViewControllers that receive a NSNotification from the app delegate. It's like a timer, but every UIViewController handle your way. My problem is: when I interact with user interface, the UIViewController doesn't receive the…