Re: C callbacks with NSNotificationCenter?

2016-09-10 Thread Andreas Falkenhahn
On 08.09.2016 at 00:47 Graham Cox wrote: >> On 8 Sep 2016, at 3:44 AM, Andreas Falkenhahn wrote: >> How can I access "IMPORTANT_DATA_PTR" from within the block above? > You already did it. Variables are captured from the scope where the > block is declared and

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Graham Cox
> On 8 Sep 2016, at 3:44 AM, Andreas Falkenhahn wrote: > > How can I access "IMPORTANT_DATA_PTR" from within the block above? You already did it. Variables are captured from the scope where the block is declared and “magically” get referenced within the block. So what

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Alastair Houghton
> On 7 Sep 2016, at 22:11, Jens Alfke wrote: > > >> On Sep 7, 2016, at 10:03 AM, Alastair Houghton >> wrote: >> >> All of it can. Objective-C is just C with some syntactic sugar on top. > > There’s a large amount of semantic sugar too,

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Jens Alfke
> On Sep 7, 2016, at 10:03 AM, Alastair Houghton > wrote: > > All of it can. Objective-C is just C with some syntactic sugar on top. There’s a large amount of semantic sugar too, i.e. the runtime libraries. (If you think the runtime part must be trivial, go

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Andreas Falkenhahn
On 07.09.2016 at 18:09 Andreas Falkenhahn wrote: > As a C programmer I'm trying to avoid Objective C whenever and wherever > possible. I think this might be prone to misunderstanding: What I meant was that I'm trying to avoid writing classes whenever and wherever possible. I don't mind using

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Andreas Falkenhahn
On 07.09.2016 at 18:33 じょいすじょん wrote: > Have you considered Core Foundation? I absolutely love Core Foundation! As you might know I'm currently migrating a Carbon project to a Cocoa one and lots of it is of course in Core Foundation and I can just re-use those parts. It's really great that

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Andreas Falkenhahn
Hi Fritz, On 07.09.2016 at 18:35 Fritz Anderson wrote: >> On 7 Sep 2016, at 11:09 AM, Andreas Falkenhahn >> 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

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Alastair Houghton
On 7 Sep 2016, at 17:09, Andreas Falkenhahn wrote: > > As a C programmer I'm trying to avoid Objective C whenever and wherever > possible. Don’t. Where there’s an Objective-C equivalent, it’ll be less error prone, shorter to write and easier to debug. > The good

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Jonathan Mitchell
> 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. I forgot to say that as long as your c function is in a .m

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread dangerwillrobinsondanger
It's not Toll Free bridged. And Fritz, you contribute so much to folks, nobody would blink if you missed anything. Sent from my iPhone > On Sep 8, 2016, at 1:41 AM, Fritz Anderson wrote: > > “dangerwillrobinsondanger” correctly points to Core Foundation. I’m >

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Fritz Anderson
“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, じょいすじょん > wrote: > > Have you considered Core

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Fritz Anderson
> On 7 Sep 2016, at 11:09 AM, Andreas Falkenhahn 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

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread じょいすじょん
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

Re: C callbacks with NSNotificationCenter?

2016-09-07 Thread Jonathan Mitchell
> On 7 Sep 2016, at 17:09, Andreas Falkenhahn wrote: > > > 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? >

C callbacks with NSNotificationCenter?

2016-09-07 Thread Andreas Falkenhahn
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