Re: MyShadow was deallocated while key value observers...
Re: MyShadow was deallocated while key value observers...
- Subject: Re: MyShadow was deallocated while key value observers...
- From: Leonardo <email@hidden>
- Date: Sat, 28 Jun 2014 13:14:58 +0200
- Thread-topic: MyShadow was deallocated while key value observers...
In MyShadow class I implemented a method called
- (BOOL)isEqualToShadow:(MyShadow*)otherShadow
that I call for my other specific issues.
So, I didn't override the "isEqual" method.
Yes the 2 MyShadows must remain distinct because they are mutable. But there
is no NSMutableShadow that I can subclass there.
How can I achieve my target?
Should I override the isEqual method this way?
- (BOOL)isEqual:(id)anObject
{
return self == anObject;
}
Regards
-- Leonardo
> Da: Ken Thomases <email@hidden>
> Data: Sat, 28 Jun 2014 04:20:20 -0500
> A: Leonardo <email@hidden>
> Cc: <email@hidden>, Lee Ann Rucker <email@hidden>
> Oggetto: Re: MyShadow was deallocated while key value observers...
>
> 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