Re: C++ pointer to Cocoa object
Re: C++ pointer to Cocoa object
- Subject: Re: C++ pointer to Cocoa object
- From: Jens Alfke <email@hidden>
- Date: Fri, 07 Sep 2018 15:48:58 -0700
> On Sep 7, 2018, at 10:46 AM, Casey McDermott <email@hidden> wrote:
>
> Problem is, with ARC turned on, the pointer is never nil, so it crashes.
> The void pointer somehow becomes an NSAtom instead of 0.
Something wrote to that pointer, then. If you initialize it to nullptr, it will
stay that way. NSAtom is a red herring — probably the mCocoaPopupPtr was
pointing to a valid object, but it got freed, and there is now (by chance) an
NSAtom instance residing at that address.
The reason the object got freed is probably that your C++ pointer isn't known
to ARC so it didn't bump the refcount of the object assigned to it. You'll need
to use CFRetain/CFRelease to manually retain objects assigned to that pointer.
—Jens
_______________________________________________
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