Reputation: 2069
This is my code to display an attributed string in a UITextView
NSMutableAttributedString *recipeString =[[NSMutableAttributedString alloc]init];
[recipeString appendAttributedString:string1];
[recipeString appendAttributedString:string2];
[array addObject:recipeString];
This code is inside a for
loop. string1
and string2
are NSMutableAttributedString
s.
After that:
self.textView.text = [array objectAtIndex:self.appDelegate.selectedCell];
The text view is an IBOutlet
.
It crashes with this exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteAttributedString _isCString]: unrecognized selector sent to instance 0x8e866f0'
Any ideas on how to fix this crash?
Upvotes: 4
Views: 2927
Reputation: 2575
For future users:
-[NSConcreteAttributedString mutableString]: unrecognized selector sent to instance
this may also be caused by if in the above instance string1
or string2
is nil
Upvotes: 0
Reputation: 2069
I had to use the attributedText
property of UITextView
:
self.textView.attributedText = [array objectAtIndex:self.appDelegate.selectedCell];
Upvotes: 8