クラッシュし続ける次のコードがあり、その理由がわかりません。
@property (nonatomic)NSUInteger numberOfShapes;
@property (strong, nonatomic)NSString *shapeInCard;
@property (strong, nonatomic)UIColor *colorOfShape;
@property (nonatomic)float shadeOfColor;enter code here
- (NSAttributedString *) contents
{
NSMutableAttributedString *cardContents = [[NSMutableAttributedString alloc] initWithString:@""];
UIColor *shapeColor = [self.colorOfShape colorWithAlphaComponent:self.shadeOfColor];
NSAttributedString * shapeToUse = [[NSAttributedString alloc] initWithString:self.shapeInCard attributes:@{NSBackgroundColorAttributeName:shapeColor}]; <-------
for (int i=0; i<self.numberOfShapes; i++) {
[cardContents appendAttributedString:shapeToUse]; <------
if(i < self.numberOfShapes-1) {
[cardContents appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
}
}
return cardContents;
}
プロパティは別の方法で設定されます。
-[__NSCFNumber length]: unrecognized selector sent to instance 0x8b54fe0
<-------- でマークされた行でこのエラーが発生し続けます。そして、私はその理由を見つけることができません。2 行目でのみクラッシュする属性セクションを削除すると、最初のマークされた行をなんとか取得できました。
誰か助けてくれませんか?
前もって感謝します。