As a C programmer I'm trying to avoid Objective C whenever and wherever 
possible.
The good thing is that I can do most interaction with Cocoa from normal C 
functions.
I only had to write very few classes. Most of the Cocoa stuff can be done
from normal C functions just fine.

Now I'd like to subscribe to the AVPlayerItemDidPlayToEndTimeNotification
notification. In an Objective C class, this is purportedly done like this:

    [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(itemDidFinishPlaying:) 
name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem];

This will call the "itemDidFinishPlaying" method in class "self" whenever
an AVPlayerItem has finished playing.

Of course, I can't use this code in a normal C function because there are
references to "self" and the selector thing doesn't look like it's compatible to
C. So I could just subclass AVPlayerItem and voila, everything's fine.

Still, I'm wondering: Is it also possible to have NSNotificationCenter call
a C function for me whenever the notification triggers? Can this somehow
be achieved or am I forced to use full Objective C here?

-- 
Best regards,
 Andreas Falkenhahn                          mailto:andr...@falkenhahn.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to