• 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: MyShadow was deallocated while key value observers...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MyShadow was deallocated while key value observers...


  • Subject: Re: MyShadow was deallocated while key value observers...
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 28 Jun 2014 04:20:20 -0500

On Jun 28, 2014, at 3:24 AM, Leonardo wrote:

> I have found the origin of the trouble.
> Shortly, when I add a second shadow to a second word and the second shadow
> has the same values as the first one (e.g. offset, blur...), the textStorage
> *automatically* replaces the second shadow with the first one. So at the end
> I get *one* shadow on two different words. But if I add the second shadow
> with different values (e.g. offset, blur...), it doesn't get replaced. That
> sounds weird. It must be a kind of textStorage's optimization.

If the Cocoa text system is coalescing two attribute values of a custom class, then it can only be because that class implements -isEqual: and -hash to indicate that the two instances are equivalent.  It couldn't possibly figure out that two MyShadow instances are the same otherwise.

If you have implemented MyShadow as a value class such that different instances compare as equal when it's not really a value class, then that seems like a problem.

For example, if the two MyShadow instances must remain distinct, perhaps because they are mutable and mutating one should not affect the other or even just that it matters to your logic which specific instance is used, then you should use the default NSObject equality mechanism that's just based on pointer identity.

Regards,
Ken


_______________________________________________

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: MyShadow was deallocated while key value observers...
      • From: Leonardo <email@hidden>
References: 
 >Re: MyShadow was deallocated while key value observers... (From: Leonardo <email@hidden>)

  • Prev by Date: Re: MyShadow was deallocated while key value observers...
  • Next by Date: Re: MyShadow was deallocated while key value observers...
  • Previous by thread: Re: MyShadow was deallocated while key value observers...
  • Next by thread: Re: MyShadow was deallocated while key value observers...
  • Index(es):
    • Date
    • Thread