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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top