On 14 May, 2013, at 10:41 AM, Graham Cox <graham....@bigpond.com> wrote:

> 
> On 14/05/2013, at 12:27 PM, Thomas Wetmore <t...@verizon.net> wrote:
> 
>> Can anyone suggest why adding the three lines in mouseDown prevents 
>> dragging? Using ARC.
> 
> 
> When you call -removeFromSuperview, the view is deleted, as there are no more 
> references to it. The other methods are not called because the object ceases 
> to exist.
> 
> You need to retain it, remove it, add it to the superview then release it. 
> ARC won't automatically help you out in this case because you're deallocing 
> self, indirectly, which is not a good idea.
> 

That depends on whether the framework which is calling mouseUp:/mouseDown: 
retains the object on which it's calling it. If the framework is using ARC and 
a normal strong reference, then it would be retained and that would stop it 
deallocing, if it's not using ARC then it depends on whether the framework 
retains the view explicitly, which it probably should since it's trying to use 
it but I have no idea whether it does or not. 

Not too hard to test, stick a breakpoint in the dealloc() method and see if 
it's called from within one of the mouseUp:/mouseDown: methods. 

If you are losing it, you can assign self to a strong reference at the start of 
the method which you nil out again after you've done your window shuffle, and 
that will hang onto it (as long as it doesn't get optimized out).


_______________________________________________

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