how do i add more strings to the combined string if the length is less than the prescribed length?

Something like below

NSString *combined = [NSString stringWithFormat:@"%@%@", stringURL, stringSearch];
if (combined.length < 16)
{
    NSString *newCombined = [NSString stringWithFormat:@"%@%@", combined, @"Some new string"];
}

You can use substringWithRange: method from NSString. You can take the below code as an example and modify it as per your requirements.

if (combined.length > 25)
{
    NSString *beginning = [combined substringWithRange:NSMakeRange(0, 15)];
    NSString *fromEnd = [combined substringWithRange:NSMakeRange(startPoint, combined.length-startPoint)];
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top