Проблема с NSAttributedString и NSMuttableAttributedString

У меня есть следующий код, который продолжает сбой и не могу найти почему.

@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 на линиях, помеченных<--------. и я не могу найти причину. Мне удалось пройти по отмеченной кулаком линии, если я исключу раздел атрибутов только для сбоя во второй строке.

Может кто-нибудь помочь?

Заранее спасибо.

0 ответов

Другие вопросы по тегам