سؤال

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