Re: Assigning an element of a swift array to a userdata parameter triggers didSet
Re: Assigning an element of a swift array to a userdata parameter triggers didSet
- Subject: Re: Assigning an element of a swift array to a userdata parameter triggers didSet
- From: Quincey Morris <email@hidden>
- Date: Wed, 18 Nov 2015 11:12:06 -0800
- Feedback-id: 167118m:167118agrif8a:167118spuspKQuYv:SMTPCORP
On Nov 18, 2015, at 10:57 , Jens Alfke <email@hidden> wrote:
>
> Doesn’t the pointer become invalid as soon as myElement goes out of scope? (There’s a reason that type is called *Unsafe*Pointer…)
Yes, but so does &myArray[0] in the original code. According to your hypothesis, it’s copied into a temporary, which also becomes invalid as soon as the current scope ends.
(I didn’t check the docs to see if the void* parameter to addToolTipRect needs a longer lifetime. If it does, then there’s manual memory management to do, regardless of what approach is taken. That’s why there ought to be a better API.)
_______________________________________________
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