• 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
Crash in Attributed String (x64)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Crash in Attributed String (x64)
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: [moderator] Re: Cocoa apps protection software
  • Next by Date: Re: Wrapping C functions in Objective C proxy objects: naming convention?
  • Previous by thread: Re: Cocoa-dev Digest, Vol 5, Issue 1988
  • Next by thread: Re: Crash in Attributed String (x64)
  • Index(es):
    • Date
    • Thread