• 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: Value of self changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Value of self changes


  • Subject: Re: Value of self changes
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 15 Nov 2013 08:28:09 +0000

On 15 Nov 2013, at 07:41, Jerry Krinock <email@hidden> wrote:

> Several years ago, I subclassed NSPopUpButtonCell and am using it as a table header cell, so the user can select which attribute is displayed in the column.  Maybe this was not a good idea, but anyhow…
>
> A few years ago, I noticed a rare, unreproducible bug in my app wherein this cell would receive -drawWithFrame:inView:, but the value of self is *different* than the original value of self, which I'd stored in an instance variable during the -init of this instance.  Weird!  (I added this instance variable for the purpose of debugging this problem.)  The cell then gets a -dealloc message, again with the “new self" shortly thereafter, and I’ve worked around the crashes which would ensue by no-opping these methods if self != the original self.  It does leak, of course.
>
> In 10.9, I see this bug occurring much more frequently.  I still don’t know how to reproduce it from launch but, at this moment, I get a handful of them whenever the width of the table columns that contain these cells is reduced.  I see them showing up in the Allocations tool in Instruments.  When I “po” them in the Debug Console, they tell me they are MyFooeyCell objects, and in general appear to be a copy of the original “self".  Allocations lists their “Responsible Caller” as NSCopyObject.  So I put breakpoints in +[MyFooeyCell alloc], -[MyFooeyCell init], -[MyFooeyCell copyWithZone:], and _NSCopyObject.  But none of them ever break.  These phonies seem to appear out of nowhere.
>
> Can anyone suggest how ’self’ could be changed?
>
> I realize this is probably a good lesson in Why It’s a Bad Idea to Use Non-Standard Controls, and if I spend too much more time on this, I’ll probably rip it out and put in more conventional column-attribute controls, probably a checkbox or a checkmark on/off menu item for each attribute.
>
> But I sure would like to know how ‘self’ could be changed.

Well the table view is entitled to copy your cell as much as it likes. Indeed if you use a cell-based table view, it does this a lot for the data cells.

Sadly -[NSCell copyWithZone:] is implemented with NSCopyObject. Do you declare any instance variables as part of your custom cell? If so, you likely need to understand how NSCopyObject() works and implement a custom -copyWithZone: method to handle it.


_______________________________________________

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


References: 
 >Value of self changes (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Value of self changes
  • Next by Date: Re: Value of self changes
  • Previous by thread: Re: Value of self changes
  • Next by thread: Re: Value of self changes
  • Index(es):
    • Date
    • Thread