How to copy NSMutableAttributedString

I'm just wondering how I can make a copy NSMutableAttributedString. I have a property textthat I would like to save its contents at a certain point and return to it if something happens. I tried to make a property called textCopywhere I can save it with @property (nonatomic, copy), but in doing so I get a runtime error:

 -[NSConcreteAttributedString insertAttributedString:atIndex:]: unrecognized selector sent to instance.

How to do it?

Updated with runtime error. I get this anytime I set NSMutableAttributedString to @property (nonatomic, copy). Not understanding why this will not work, in the general case, the copy parameter does not work with NSMutableAttributedString, whether I use its setter method or not.

0
source share
1

, copy . copy . copy . NSAttributedString, NSMutableAttributedString.

- , mutableCopy, , ARC:

- (void)setTextCopy:(NSMutableAttributedString *)text {
    textCopy = [text mutableCopy];
}

, :

- (void)setTextCopy:(NSMutableAttributedString *)text {
    [textCopy release];
    textCopy = [text mutableCopy];
}

, textCopy NSAttributedString NSMutableAttributedString, .

+4

All Articles