Intermittent failure while configuring NSMutableAttributedString

I have code to configure NSMutableAttributedString:

    NSMutableParagraphStyle *centred = [[NSMutableParagraphStyle alloc]init];
    [centred setAlignment:NSCenterTextAlignment];
    NSDictionary *attributes = [[NSDictionary alloc]initWithObjectsAndKeys:[NSFont fontWithName:@"Helvetica bold" size:12],NSFontAttributeName,
                                [NSColor whiteColor],NSForegroundColorAttributeName,
                                [NSColor clearColor], NSBackgroundColorAttributeName, 
                                centred, NSParagraphStyleAttributeName,
                                nil];
    NSMutableAttributedString* attribTitle = [[NSMutableAttributedString alloc]initWithString:@"Foo"];
    [attribTitle setAttributes:attributes range:NSMakeRange(0, [[attribTitle string] length] - 1)];

It has been sitting in my appawawFromNib method almost since I started the project without problems, but only today I started every attempt to launch the application in Xcode 4.3 "Thread 1: EXC_BAD_ACCESS (code = 1, address = 0x10)" failed. This breaks down in the final line ... setAttributes .... At some point I tried to use the method - initWithString: attributes: to initialize the title attribute and, of course, the crash (when it did) was in the alloc-init line.

I tried to clear the Xcode reboot, but it still happens with every other build ... If the application does not work, the attrbibuted line will appear as expected.

, , - , - - NSDictionary '?

!

.

+3
1

, , ? , ( ). , , .

, -awakeFromNib: - , ? , , , , IB MainMenu.xib, , NIB -[super initWithWindowNibName:] -init:. -awakeFromNib NIB. , , .

-windowWillLoad -windowDidLoad, , .

+1

All Articles