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 (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