1

I want an NSNotification to be triggered when a non date based event occurs. Any ideas? Thanks!

4

1 回答 1

1

You have to create an NSNotification and add this notification to the default notification centre. You can do this in that unique line :

[[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:object userInfo:dictionary];

You then have to say to your project that when a notification is sent with the name notificationName, trigger this specific method on my code. And this is done with :

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationMethod) name:notificationName object:object];

There is a full tutorial here.

于 2013-03-30T17:29:25.383 回答