Reputation: 95
I need to create a NSString
for browsing folders in FTP share. i show the directory on a TableView, and user´s can browse by selecting row ´s
Im writing the string of selected rows into a mutable array, and then i need to make a string of all strings in the mutable array. means add the last string to the previous when the row is selected
for example first string in array is "Downloads" second "Movies" third "HD-Movies"....... and so on for that i need the string on the first time selected row "/Downloads/" the second time "/Downloads/Movies/", an the third "/Downloads/Movies/HD-Movies"
i´m sure i need a NSMutableString
, but don´t know how to add the strings...
here a part of my code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *filePathArray = [[NSMutableArray alloc]init];
[filePathArray addObject:@"/Downloads/"];
[filePathArray addObject:[fileNameArray objectAtIndex:indexPath.row]];
}
Upvotes: 2
Views: 477
Reputation: 46563
You can do like this:
NSString *string=[array componentsJoinedByString:@"/"];
This will give you :
Downloads/Movies/HD-Movies
Now if you want /
in front than you can simply append an /
.
Upvotes: 4