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

How can I observe when an NSURLConnection is cancelled?

How can I observe when an NSURLConnection is cancelled? I have a method. - [TSMWebServer sendPage: withArguments: etc...] The sendPage method returns an "NSURLConnection" pointer. I need the webserver to notice when the NSURLConnection is…
0
votes
1 answer

Does NSNotification somehow use threads internally?

NSNotification is non-blocking call. Does it mean it runs threads internally somehow ? If not what happens actually: when observer receives the event it executes the handler then the observee continues ? In that case non-blocking is actually fake ?
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
2 answers

How to stay MVC!! :)

I am very new to coding but I am striving to maintain a MVC design pattern at all costs! I have an app whereby a tableview is selected which pushes to a new tableview. The plist and dictionaries are dealt with in the model class and it returns an…
Rob W
  • 591
  • 1
  • 7
  • 22
-1
votes
1 answer

NSNotification problem - not calling the function

give me some advice, plz. A.m NSDate *todayDate = [NSDate date]; NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init]autorelease]; [dateFormat setDateFormat:@"yy-MM-dd"]; todayString = [dateFormat stringFromDate:todayDate]; …
-1
votes
1 answer

Singleton & Notification

I have been developing Cocoa Apps for a while and I have a conceptual question regarding the Singleton "pattern" and the use of the NSNotificationCenter for communication. Suppose I have a class that is responsible for storing the credentials of the…
-1
votes
1 answer

How to use object received from NSNotification in viewWillAppear:

Here is my method that my ViewControllerA implements as part of a NSNotification system: - (NSInteger)updateTortoiseLevel:(NSNotification*)notification { _updateValue = 0; if ([notification.name isEqualToString:@"gameToTortoise"]) { …
-1
votes
2 answers

Do I need to add observer if I have a func to take NSNotification as parameter

Just like the question title for say I have code like func receieveNotification(notification : NSNotification) { ......verify notification ......retrieve userInfo } Do I still need to add observer to NSNotificationCenter.defaultCenter()…
Jay Hu
  • 6,041
  • 3
  • 22
  • 33
-1
votes
4 answers

Not getting push notifications with ADHoc certificates

I am testing push notifications with production.pem with ADHoc provisioning certificates. From server side sending successfully but device is not getting notifications. Please help me Thank you
-1
votes
4 answers

Notifying multiple view controllers and passing a value back to the notifier

I need to send a message to multiple objects at a time, and then pass a value back from each. Delegates can be used only one at a time, and notifications cannot return values. Is there any way that a tab bar controller containing two view…
S.J
  • 3,063
  • 3
  • 33
  • 66
-1
votes
1 answer

Using NSNotification to detect UIButton push to change UIWebView

I have two buttons in my VC and currently they both are connected to their respective pdf files. There is another button, Push, that goes to the rootviewcontroller. In the RVC I have a UIWebView. How can I make it so that if I push button A, a.pdf…
-1
votes
2 answers

setting an array from another view in objective c

I have a class which can be accessed from all other pages just like facebook chat head bubble.Its a cart in my application.Items to the cart could be added from different views. HAve tried with NSNotification and is not working.The array inside the…
iOS Developer
  • 1,723
  • 2
  • 16
  • 47
-2
votes
1 answer

Can I use NSNotificationCenter selector method in multiple view controllers?

I have this ViewControllerA that pushes ViewControllerB onto the navigation stack, which pushes ViewControllerC onto the stack. From ViewControllerB, I can pop to ViewControllerA. And from ViewControllerC, I can pop to ViewControllerA. I need to…
1 2 3
20
21