سؤال

I create a NSMutableAttributedString in the init method of a view by doing this:

self.name = [[NSMutableAttributedString alloc] initWithString:@"Gabe Jacobs"];

How do I update the string within it without initing again? I don't want to have to create a new one every time. Any idea?

هل كانت مفيدة؟

المحلول

NSMutableString *string = [NSMutableString stringWithString:@"first"];
[string replaceCharactersInRange:NSMakeRange(0, string.length) withString:@"second"];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top