1 /**
2 * 路径合并案例
3 * stringByTrimmingCharactersInset:
4 */
5 #import <Foundation/Foundation.h>
6
7 int main(int argc, const char * argv[]) {
8 @autoreleasepool {
9
10 NSString *path=@"Users/apple/Desktop";//文件路径
11 NSString *file=@"test.html";//文件名
12
13 //NSLog(@"%@",path stringByTrimmingCharactersInSet)//去除字符 如果有就去除 没有则不改变
14 //合并路径
15 NSString *filePath=[NSString stringWithFormat:@"/%@/%@",[path stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"/" ]],file];
16
17 NSLog(@"%@",filePath);//打印结果:/Users/apple/Desktop/test.html
18
19
20 }
21 return 0;
22 }