Question

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

Était-ce utile?

La solution

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

NSMutableString *string = [self.label.text mutableCopy];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top