Shorten an NSString?
I h开发者_StackOverflow中文版ave a very simple question. Is there a built in method to shorten strings? If not can someone provide an example of doing that in ObjC?
For example:
ThisIsAVeryLongString
should become
ThisIsAV...
It needs to check if the string is over a certain amount of characters and if it is shorten it.
It's pretty straightforward...
NSString *originalString = @"SomethingVeryLong";
int newLength = 9;
if (originalString.length > newLength)
NSString *shortString = [originalString substringToIndex:newLength];
精彩评论