You can only have a method
- (NSString *)stringOrEmptyString:(NSString *)string
{
if (string)
return string;
else
return @"";
}
and then just
[NSString stringWithFormat:@"%@/%@/%@",
[self stringOrEmptyString:three],
[self stringOrEmptyString:two],
[self stringOrEmptyString:one]];
Update:
Alternatively, if you do not want to have slashes, if there were empty values, you could do something like:
NSMutableArray *array = [[NSMutableArray alloc] init];
if (one)
[array addObject:one];
if (two)
[array addObject:two];
if (three)
[array addObject:three];
Then you can get the NSString result with something like:
[array componentsJoinedByString:@"/"]
, , , ARC, [array release].