monish monish - 2 years ago 153
Objective-C Question

How to truncate the string into required length in iphone sdk?

I am having a string which contains more the 25 characters;

NSString *str = @"This is the string to be truncated to 15 characters only";

In the above string I need only the 15 characters to be stored in another variable after truncation.

can anyone suggest me how to do this?
Anyone's help will be much appreciated.

Thank you,

tc. tc.
Answer Source
str = [str substringToIndex: MIN(15, [str length])];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download