• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C callbacks with NSNotificationCenter?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C callbacks with NSNotificationCenter?


  • Subject: Re: C callbacks with NSNotificationCenter?
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 07 Sep 2016 11:41:00 -0500

“dangerwillrobinsondanger” correctly points to Core Foundation. I’m embarrassed to have forgotten — it should be very helpful to you, assuming it mixes with AVFoundation.

> On 7 Sep 2016, at 11:33 AM, じょいすじょん <email@hidden> wrote:
>
> Have you considered Core Foundation?
>
> https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFNotificationCenterRef/
> It is all C
>
> Another alternative is to look at the Objective-C runtime library routines.
> You can do a lot with the language from C...
>
>> On 2016 Sep 8, at 1:09, Andreas Falkenhahn <email@hidden> wrote:
>>
>> 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:email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: C callbacks with NSNotificationCenter?
      • From: email@hidden
References: 
 >C callbacks with NSNotificationCenter? (From: Andreas Falkenhahn <email@hidden>)
 >Re: C callbacks with NSNotificationCenter? (From: じょいすじょん <email@hidden>)

  • Prev by Date: Re: C callbacks with NSNotificationCenter?
  • Next by Date: Re: C callbacks with NSNotificationCenter?
  • Previous by thread: Re: C callbacks with NSNotificationCenter?
  • Next by thread: Re: C callbacks with NSNotificationCenter?
  • Index(es):
    • Date
    • Thread