Im inserting a string into a NSMutableString like as

NSMutableString *string = (NSMutableString *)self.label.text;
[string insertString:@"New " atIndex:0];

these line of codes working properly iOS 6 device. but in iOS 7 it throws an exception as Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds' (i'm running ios 6 app in ios 7 device).

can any body tell why it's happening? please.

thanks

有帮助吗?

解决方案

You can't convert an NSString to an NSMutableString simply by casting. Do this instead:

NSMutableString *string = [self.label.text mutableCopy];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top