Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Are you doing it in this way?</p> <p><strong>/* Define a helper method */</strong></p> <pre><code>- (NSString *)formattedStringWithStrings:(NSArray *)strings { NSString *str1 = [[strings objectAtIndex:0] stringByPaddingToLength:3 withString:@" " startingAtIndex:0]; NSString *str2 = [[strings objectAtIndex:1] stringByPaddingToLength:20 withString:@" " startingAtIndex:0]; NSString *str3 = [[strings objectAtIndex:2] stringByPaddingToLength:3 withString:@" " startingAtIndex:0]; NSString *str4 = [[strings objectAtIndex:3] stringByPaddingToLength:10 withString:@" " startingAtIndex:0]; NSString *str5 = [[strings objectAtIndex:4] stringByPaddingToLength:15 withString:@" " startingAtIndex:0]; return [NSString stringWithFormat:@"%@%@%@%@%@", str1, str2, str3, str4, str5]; } </code></pre> <p><strong>/* Use the helper method */</strong></p> <pre><code>NSArray *strings = [NSArray arrayWithObjects:@"1", @"faizan", @"1", @"locked", @"10/20/2008", nil]; NSLog(@"%@", [self formattedStringWithStrings:strings]); strings = [NSArray arrayWithObjects:@"2", @"faizanali", @"1", @"locked", @"10/20/2008", nil]; NSLog(@"%@", [self formattedStringWithStrings:strings]); strings = [NSArray arrayWithObjects:@"3", @"ali turab gilani", @"1", @"locked", @"10/20/2008", nil]; NSLog(@"%@", [self formattedStringWithStrings:strings]); </code></pre> <p><strong>/* And the output */</strong></p> <pre><code>1 faizan 1 locked 10/20/2008 2 faizanali 1 locked 10/20/2008 3 ali turab gilani 1 locked 10/20/2008 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload