• 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: Mixing Obj-C and C "methods"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing Obj-C and C "methods"


  • Subject: Re: Mixing Obj-C and C "methods"
  • From: Vincent Habchi <email@hidden>
  • Date: Tue, 30 Jul 2013 17:54:11 +0200

Hi and thanks a lot to anybody!

I posted some answer before, but since it included a screenshot I’m afraid it didn’t make it through. I was just trying to show that when I access an iVar of ‘self’ in the C-function (e.g. self -> _egg), Xcode autocompletion pop-up shows the iVars list, but each one is crossed-off; I was wondering if this was an Xcode bug.

> So you'd be able to access the myObj member of the struct without having to cast.  But you'd have to make sure myObj doesn't get dealloc'ed before the struct is used (i.e., before the callback is invoked), so maybe you wouldn't be doing any less work code-wise.

No, it would be perfectly fine. The way SQLite works, after a query is submitted, the thread is suspended and a callback is repeatedly executed to store each row of the result, until the response is exhausted; the query-thread is then released (i.e. the query submission call returns). So there is no risk for the calling object to be de-allocated (at least the way I code it).

> Apple's recommended alternative to having a struct contain an object is to use a class instead of a struct.  You could create a MyCallbackInfo class with two properties: the query id and the pointer to self.  You'd still have to bridge-cast *that* object when passing it to the callback.

Makes me think of that French saying: “it’s like using a pneumatic drill to crack a nut”.

Thanks for everybody’s advice.
_______________________________________________

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: Mixing Obj-C and C "methods"
      • From: Quincey Morris <email@hidden>
    • Re: Mixing Obj-C and C "methods"
      • From: John McCall <email@hidden>
References: 
 >Mixing Obj-C and C "methods" (From: Vincent Habchi <email@hidden>)
 >Re: Mixing Obj-C and C "methods" (From: Rick Mann <email@hidden>)
 >Re: Mixing Obj-C and C "methods" (From: Vincent Habchi <email@hidden>)
 >Re: Mixing Obj-C and C "methods" (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Mixing Obj-C and C "methods"
  • Next by Date: Re: Exiting non-POSIX threads?
  • Previous by thread: Re: Mixing Obj-C and C "methods"
  • Next by thread: Re: Mixing Obj-C and C "methods"
  • Index(es):
    • Date
    • Thread