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
0 answers

detect why iOS app went into background, hardware home or incoming push notification

I want my app to behave differently if the user pushes hardware home button, versus other reasons it may go into background. I think I have sorted out the main cases, except I can't tell the difference between user tapping on incoming push…
user1055568
  • 1,349
  • 13
  • 21
0
votes
1 answer

How to become an observer of a property of an object stored in an NSArray?

I am trying to make a view controller an observer of a property (an enum) of one of its child view controllers. The view controller whose property I am trying to access is stored in an NSArray. It seems that I cannot do something like…
0
votes
1 answer

Many to one relationship messaging, KVO or NSNotification

Could someone please advise me on best or practical way of creating a many to one relationship messaging system. I am new to Objective-C so if this something that I "should know" as an Obj-C developer, please feel free to point me in the right…
0
votes
2 answers

NSNotification - information not passing through from a different class

I am building a program that utilises NSNotification as I want to be able to pass information through from another class that is going to affect the value of variables in a different class. So, I have set up the following: categories.m class: In…
0
votes
1 answer

Removal of core data object does not nullify all of its relations?

I have an entity called Task which has a to-one relationship with the entities TaskTemplate and Occurrence. Both of these entities have to-many relationships with Tasks. Deletion rules are set to Nullify. Within an Occurrence, I try to remove all…
0
votes
2 answers

NSNotification - observer not match

I use NSNotificationCenter: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playNow:) name:@"PlayNow" object:nil]; and Post: [[NSNotificationCenter defaultCenter] postNotificationName:@"PlayNow" object:nil…
Jakub
  • 13,712
  • 17
  • 82
  • 139
0
votes
2 answers

Remove notification observer in superclass or subclass in ios

I have registered for a notification in the superclass. The observer is handled in the subclass which calls the super implementation. Do I remove the observer in the dealloc of the superclass or subclass ?
VBK
  • 1,435
  • 1
  • 15
  • 34
0
votes
1 answer

Notification Observer is not catching the post

I have a split view controller, and the child masterView is attempting to send out a post notification under certain conditions in the 'viewDidAppear' method. However, the Observer that is located in the parent isn't ever being triggered. Here is…
JMD
  • 1,540
  • 2
  • 24
  • 56
0
votes
1 answer

NSNotificationCenter for AddressBook db

I want to identify the address book changes in my app using NSNotificationCenter how to use Please help me.
Karthick
  • 382
  • 1
  • 3
  • 23
0
votes
2 answers

Is NSNotificationCenter necessary to cancel UILocalnotficiation?

I want to cancel a UILocalnotification , when i cancel notification still the notification is being fired . I wanted to know do i have to call any delegate method in appdelegate to cancel notification .the code which i am using is executing…
raptor
  • 291
  • 1
  • 9
  • 17
0
votes
2 answers

In iOS how to get Global touch event notification in background running state?

I am looking for a way to get notified about any user initiated touch event while my app is in background running state, I want to make it clear I don't want to handle gesture events or break UIResponder chain, some form of notification that user…
Abhinav Singh
  • 7,880
  • 1
  • 23
  • 33
0
votes
3 answers

How to have information that a touch event has happened and what kind of touch event and not handle it?

i want to create an NSNotification for all the the touch events happening with there specific recognise types and not handling them just observing them, any ideas?
0
votes
2 answers

Sending NSNotifications to all objects of a class

I have an object that can be selected by a user click. With the current requirements of the app, at any time, there is no more than one of these items selected at any point during app execution. I implemented a mechanism to enforce this, as…
Liron
  • 2,012
  • 19
  • 39
0
votes
2 answers

sending a NSNotification between views

This is my first attempt with NSNotification, tried several tutorials but somehow it's not working. Basically I am sending a dictionary to class B which is popup subview (UIViewController) and testing to whether is has been received. Could anyone…
Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78
0
votes
1 answer

NSNotificationCenter: removeAllObserver for self works for several observing objects?

Say if I have several: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationReceived:) name:NotificationA …
hzxu
  • 5,753
  • 11
  • 60
  • 95