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)];
ほとんど問題なくプロジェクトを開始して以来、アプリの -awakeFromNib メソッドに座っていましたが、今日、Xcode 4.3 でアプリを実行しようとすると、「Thread 1:EXC_BAD_ACCESS (code=1,アドレス=0x10)」。最後の '...setAttributes...' 行で中断されます。ある時点で、メソッド initWithString:attributes: を使用して attribTitle を初期化しようとしましたが、(そうなったときに) クラッシュが alloc-init 行にあったことを確認しました。
Xcodeの再起動をクリアしようとしましたが、他のすべてのビルドで引き続き発生します...アプリがクラッシュしない場合、属性付きの文字列が期待どおりに表示されます。
プロジェクトファイルが壊れているかどうか疑問に思っていますが、念のため、何かばかげたことをした場合に備えて、誰かが間違いを指摘できますか?おそらく「属性」NSDictionary にありますか?
ありがとう!
トッド。