I have the following code that keeps crashing and can't find why.
@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;
}
The properties are set by another method.
I keep getting this error -[__NSCFNumber length]: unrecognized selector sent to instance 0x8b54fe0
on the lines marked with <--------. and I can't find the reason.
I have managed to get by the fist marked line if I eliminate the attributes section only to crash at the second line.
Can someone help?
Thanks in advance.