• 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
Very annoying bug with NSMutableAttributedString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Very annoying bug with NSMutableAttributedString


  • Subject: Very annoying bug with NSMutableAttributedString
  • From: Jérôme Laurens <email@hidden>
  • Date: Tue, 27 Apr 2004 11:56:16 +0200

Hi all,

here is a main.m file for a test foundation tool
I just create two NSMutableAttributedString,
for MAS1, I just append @"X" to a void mutable attributed string
for MAS2, initWithString:attributes: is used with @"X" and no attributes

We do have [MAS1 isEqual: MAS2] but [MAS2 description] raises an
exception

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSMutableAttributedString * MAS1 = [[[NSMutableAttributedString
alloc] init] autorelease];
NSLog(@"MAS1 is: %@", [MAS1 description]);
[[MAS1 mutableString] appendString: @"X"];
NSLog(@"MAS1 is: %@", [MAS1 description]);
NSMutableAttributedString * MAS2 = [[[NSMutableAttributedString
alloc] initWithString: @"X" attributes: [NSDictionary dictionary]]
autorelease];
NSLog(@"MAS1 %@ MAS2", ([MAS1 isEqual: MAS2]? @"equals": @"NOT
equals"));
NSLog(@"MAS2 is: %@", [MAS2 description]);
NSLog(@"Hello, World!");
[pool release];
return 0;
}

The output is

2004-04-27 11:50:53.539 NSMAS[17267] MAS1 is:
2004-04-27 11:50:53.598 NSMAS[17267] MAS1 is: X{}
2004-04-27 11:50:53.599 NSMAS[17267] MAS1 equals MAS2
2004-04-27 11:50:53.599 NSMAS[17267] *** Uncaught exception:
<NSRangeException> *** -[NSCFString substringWithRange:]: Range or
index out of bounds

NSMAS has exited due to signal 5 (SIGTRAP).
Showing that the initWithString:attributes: returns something in an
inconsistent state.

I am running 10.3.3
No related remark on mamasam.
I don't know how to search apple site for such bugs

Do you experience such a thing?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Very annoying bug with NSMutableAttributedString
      • From: "Louis C. Sacha" <email@hidden>
    • Re: Very annoying bug with NSMutableAttributedString
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: NSBezierPath containsPoint question
  • Next by Date: Re: xCode 1.2
  • Previous by thread: Re: How to read hard disk sectors
  • Next by thread: Re: Very annoying bug with NSMutableAttributedString
  • Index(es):
    • Date
    • Thread