#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSArray *array = [[NSArray alloc] initWithObjects:@"/tmp/1.txt" ,@"/tmp/2.txt", nil];
NSLog(@"%@", array);
NSString *result = [[NSString alloc] init];
NSArray *array2 = [[NSArray alloc]initWithArray:[result stringsByAppendingPaths:array]];
NSLog(@"%@", array2);
}
return 0;
}
The argument we provide to stringsByAppendingPaths: is an array and so is the return type. So what is the use of this NSString method?
Well, you’re appending empty string (
result), so it doesn’t make much sense. But if your receiver contains say/tmpand the array contains1.txtand2.txt, getting the array/tmp/1.txtand/tmp/2.txtmakes sense.