nsnotificationcenter

NSOperation and NSNotificationCenter on the main thread

I have an NSOperation. When it is finished I fire a NSNotificationCenter to let the program know that the NSoperation is finished and to update the gui. To my understanding listeners to the NSNotification will not run on the main thread because the NSOperation is not on the main thread. How can I make it so that the listeners run on...

motionBegan and enabled breakpoints in Xcode

So ... we have this bit of motion detection: - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake) { [[NSNotificationCenter defaultCenter] postNotificationName:@"ShakeBegan" object:self]; } } Innocuous enough. We also c...

NSNotification not being sent when postNotificationName: called

I'm trying to get one instance of using NSNotificationCenter with addObserver and postNotificationName but I can't work out why it won't work. I have 2 lines to code to add the observer and send the message in 2 different classes [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(newEventLoaded:) name:@"Event" obj...

How to send and receive message through NSNotificationCenter in Objective-C?

Hi I need a simple example program to send and receive a message through NSNotificationCenter in Objective-C ??? ...

How to enhance a simple NSNotificationCenter to NSNotificationQueue program?

Hi, I have done with a small program to send and receive message, i also wanted to enhance the program by giving muliple events and maintain a NSNotificationQueue? Please do give me a example.. ...

How to create a class to send and receive events through NSNotificationCenter in Objective-C?

Hi, I need to create two classes and both should be able to send and receive the events through the NSNotificationCenter methods.ie Both should have the sendEvent and receiveEvent methods: @implementation Class A -(void)sendEvent { addObserver:--- name:---- object:--- } -(void)ReceiveEvent { postNotificationName: --- object...

NSNotification vs. Delegate Protocols?

I have an iPhone application which basically is getting information from an API (in XML, but maybe JSON eventually). The result objects are typically displayed in view controllers (tables mainly). Here is the architecture right now. I have NSOperation classes which fetch the different objects from the remote server. Each of these NSOpe...

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 run in method to present the passcode entry form [[NSNotificationCenter defaultCen...

iPhone - Launching selectors from a different class

Hi, I'd like to reload a table view which is in another class called "WriteIt_MobileAppDelegate" from one of my other classes which is called "Properties". I've tried to do this via the NSNotificationCenter class - the log gets called but the table is never updated. Properties.h: [[NSNotificationCenter defaultCenter] postNotification...

Invalidating UITableView contents

I have an application with several UITableViewControllers. Now, the user is allowed to change "Data source". In that case I need to invalidate (reset) data in the relevant UITableViews. I figured out, that I can use NSNotificationCenter and add these controllers as observers to events which will be generated when the data source changes...

NSNotification center may not respond to -object ?

Hi, I'm trying to make simple use of the NSNotification center inside my iPhone application, but I seem to be doing something wrong in this case. I was under the impression that it was possible to retrieve an object associated with a particular message, or at least a reference to the object, but using the following example code I'm ge...

Tableview reload data problem iphone sdk

Hi all, I have a class A which is a subclass of uitableviewcontroller and one more class B which actually displays my tableview with its content is a subclass of A. There's an xml parser which parses my xml and stores the content in an nsmutablearray of application delegate. Now, I fetch this delegate array into a local nsmutablearray ...

Warning about duplicate NSNotification observations

This isn't a question so much as a warning to others to save them some time. NSNotificationCenter on iOS 3/iPhone OS 3 (I'm assuming also Mac OS X and iOS 4) has the following behavior: If you register yourself multiple times for the exact specific notification, NSNotificationCenter will NOT recognize the redundancy and instead will fi...

Why does NSNotificationCenter throw an exception when I release it?

This isn't so much a question as a pondering thought - why does NSNotificationCenter throw an exception when it's released? I'm still new to iPhone development, and thus don't know the innards of Cocoa yet, so it'd be good to understand why. I'm assigning the defaultCenter to a variable, calling addObserver:selector:name:object and then...

NSNotificationCenter selector not being called

Hi, In my iPad app, in one class I register for a notification: NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(selectedList:) name:@"TTSelectedList" object:nil]; My selectedList: method looks like this: - (void)selectedList:(NSNotification*)notification { NSLog(@"rece...

NSNotifications only being sent within the same object

Hey there, so I've got an NSObject subclass sending out a message via the notification center, and I'm sending out my notifications out to the object nil but the only object that can receive notifications is the one sending them I've got two notifications being sent out at the same time (to test if it is a threading issue) [[NSNotif...

Adding an observer to an NSString

Hi, In my application delegate I have an NSString which can be modified by a class. What I want to do is to have another class observe this NSString and to react whenever this NSString is changed. Does anybody know how I can do this? Best regards, Paul Peelen ...

Keyboard - move ViewController up when keyboard pops up.

Hello, I have a number of text fields on a view controller, when the keyboard appears, it covers some of the text field that are towards the middle of the view controller. Is there a way to move the ViewController up when the keyboard appears. Stephen ...

NSNotificationCenter sender equality criteria

Does NSNotificationCenter use pointer equality or some other criteria (like isEqual: or hash:) to determine whether a notification should be sent to an observer? ...

NSNotification-implementation for other class events?

HI, in my ViewController.m i´ve added a NSNotification in "viewDidLoad" like this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageControlChanged:) notificationName:@"ScrollViewDidEnd" object:nil]; Then i´ve a custom scr...