Crash in Attributed String (x64)
Crash in Attributed String (x64)
- Subject: Crash in Attributed String (x64)
- From: Russ <email@hidden>
- Date: Thu, 20 Nov 2008 10:52:33 -0800 (PST)
I'm trying to change the color of a button's text by setting it's title using an attributed string; there are code snippets on the web, but I'm seeing a crash
NSAttributedString *attrTitle;
NSDictionary *dict;
dict = [NSDictionary dictionaryWithObjectsAndKeys:
colr, NSForegroundColorAttributeName,
nil];
attrTitle = [[NSAttributedString alloc] initWithString:titl attributes:dict];
NSLog(@"Title %@\n", [attrTitle string]);
NSLog(@"Color %@\n", [colr description]);
[bp setAttributedTitle:attrTitle];
Crash is in this last line, in realizeClass within _objc_fixupMesageRef
The NSLog calls produce the proper results with no fuss.
I've seen the same crash with several flavors of code.
NSMutableAttributedString *attrTitle;
int len;
NSRange rng;
len = [titl length];
rng = NSMakeRange(0, len);
attrTitle = [[NSMutableAttributedString alloc] initWithString:titl];
[attrTitle beginEditing];
[attrTitle addAttribute:NSForegroundColorAttributeName value:colr range:rng];
[attrTitle endEditing];
Crash is within endEditing
Initial version based on web source:
NSMutableAttributedString *attrTitle;
int len;
NSRange rng;
len = [titl length];
rng = NSMakeRange(0, len);
attrTitle = [[NSMutableAttributedString alloc] initWithString:titl];
[attrTitle addAttribute:NSForegroundColorAttributeName value:colr range:rng];
[attrTitle fixAttributesInRange:rng];
Crash is in fixAttributesInRange
So the problem is occuring in the Attributed String stuff itself, not in the button.
This kind of stuff drives me nuts! I'll try recompiling in 32-bit later for comparison.
_______________________________________________
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