• 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: Changing Subview Order Prevents Dragging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing Subview Order Prevents Dragging


  • Subject: Re: Changing Subview Order Prevents Dragging
  • From: Roland King <email@hidden>
  • Date: Tue, 14 May 2013 11:14:32 +0800

On 14 May, 2013, at 10:41 AM, Graham Cox <email@hidden> wrote:

>
> On 14/05/2013, at 12:27 PM, Thomas Wetmore <email@hidden> 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 (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: Changing Subview Order Prevents Dragging
      • From: Graham Cox <email@hidden>
References: 
 >Changing Subview Order Prevents Dragging (From: Thomas Wetmore <email@hidden>)
 >Re: Changing Subview Order Prevents Dragging (From: Graham Cox <email@hidden>)

  • Prev by Date: ImageKit questions
  • Next by Date: Re: Changing Subview Order Prevents Dragging
  • Previous by thread: Re: Changing Subview Order Prevents Dragging
  • Next by thread: Re: Changing Subview Order Prevents Dragging
  • Index(es):
    • Date
    • Thread