• 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: reused tableViewCell UILabel text is deallocated but not nil ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reused tableViewCell UILabel text is deallocated but not nil ??


  • Subject: Re: reused tableViewCell UILabel text is deallocated but not nil ??
  • From: nicolas berloquin <email@hidden>
  • Date: Thu, 7 Oct 2010 18:30:38 +0200


Le 7 oct. 2010 à 18:06, Keary Suska <email@hidden> a écrit :

> On Oct 7, 2010, at 8:09 AM, Nicolas Berloquin wrote:
>
>> Hi !
>>
>> I have a UITableView that creates/reuses tableViewCells (
>> UITableViewCellStyleDefault) on demand, as is usually done,
>> ie cellForRowAtIndexPath: uses the same cells over and over.
>
> What do you mean, "uses over and over"? Every cell in the table must be a different object. You aren't using the same cell object for every row, are you?

No of course, I either get a free cell for reuse or create a new one if the method returns nil. (cf wwdc)
>
>> When I delete a few rows, then add a new one, I crash when I try to set the
>> cell's UILabel (right after the cell reuse):
>>
>> cell.textLabel.text = myName.titre;
>
> Backtrace?

I don't have it with me but it went down to a CFString compare a few lines down the stack from the assignment. And the disallocated adress corresponds to the _text field of the UILabel in the debugger.

>
>> I turned on zombies, and I checked with the debugger, and the textLabel's
>> _text is the deallocated instance
>> (myName.titre is good).
>
> This may be a red herring as the state of _text should not effect the ability to assign the property value, generally speaking.

Unless they compare the strings before they replace them which is what they seem to do.

I have changed my code to do a copy o the string before I assign it to the label and it works. What I don't understand is why the API doesn't either retain or copy it !!

>
>> *** -[CFString class]: message sent to deallocated instance 0x17c370
>
>> Since I'm not handling the cell's contents myself, I don't understand how
>> the textLabel can become garbage.
>> the text field is supposed to be copied on assignement...
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
_______________________________________________

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: reused tableViewCell UILabel text is deallocated but not nil ??
      • From: glenn andreas <email@hidden>
References: 
 >reused tableViewCell UILabel text is deallocated but not nil ?? (From: Nicolas Berloquin <email@hidden>)
 >Re: reused tableViewCell UILabel text is deallocated but not nil ?? (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: init returns nil or raises exception?
  • Next by Date: Re: How does Popup menu receive keyboard events?
  • Previous by thread: Re: reused tableViewCell UILabel text is deallocated but not nil ??
  • Next by thread: Re: reused tableViewCell UILabel text is deallocated but not nil ??
  • Index(es):
    • Date
    • Thread