• 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: Jonathan Mitchell <email@hidden>
  • Date: Wed, 07 Sep 2016 17:58:01 +0100

> 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 file you can create and manipulate Obj-C objects freely.

void testNsObjectInCfunc() {
    NSString *q = @"Am I alive";
}

Self is just a pointer to an object so within your c Functions you can cast it to the right type and call methods etc at will.
Obj-C methods are C functions that receive self as a parameter.

Note that using the CF objects is generally more of a challenge than using NSObject objects.

Jonathan
_______________________________________________

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


References: 
 >C callbacks with NSNotificationCenter? (From: Andreas Falkenhahn <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