• 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: NSAttributedString always returns NO for -isEqualToAttributedString with attachments present?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAttributedString always returns NO for -isEqualToAttributedString with attachments present?


  • Subject: Re: NSAttributedString always returns NO for -isEqualToAttributedString with attachments present?
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 7 Oct 2009 09:07:25 -0700


On Oct 7, 2009, at 6:12 AM, Jim Correia wrote:

The documentation for -[NSAttributedString isEqualToAttributedString:] says:

Attributed strings must match in both characters and attributes to be equal.

It doesn't mention attachments at all.

Consider the following code:

attributedString is the input string, and it may contain image attachments

NSData *d = [NSKeyedArchiver archivedDataWithRootObject: attributedString];
NSAttributedString *s1 = [NSKeyedUnarchiver unarchiveObjectWithData: d];
NSAttributedString *s2 = [NSKeyedUnarchiver unarchiveObjectWithData: d];


	NSLog(@"isEqual = %d", [s1 isEqualToAttributedString: s2]);

When 'attriburedString' does not contain image attachments, 1 is logged.

When 'attributedString' does contains image attachments, 0 is logged.

Is this the expected behavior? The correct behavior?

Attributed string comparison for equality is somewhat problematic, because there are so many different types of attribute values. Some are simple value objects, with a straightforward equality comparison, but some--notably attachments, blocks, and lists--are not, and don't really have a notion of equality distinct from identity. If you need to compare two attributed strings, you may need to consider exactly what notion of equivalence you're looking for, and implement something to test for that.


Douglas Davidson

_______________________________________________

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: 
 >NSAttributedString always returns NO for -isEqualToAttributedString with attachments present? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Triggering a Method when a Core Data Property is Altered.
  • Next by Date: Re: app delegate +initialize
  • Previous by thread: NSAttributedString always returns NO for -isEqualToAttributedString with attachments present?
  • Next by thread: [iPhone] In App Purchase Voodoo?
  • Index(es):
    • Date
    • Thread