美文网首页
OC - stringByAppendingPathCompon

OC - stringByAppendingPathCompon

作者: 千山小畻 | 来源:发表于2016-06-19 17:09 被阅读4071次
1. stringByAppendingString是字符串拼接,拼接路径时要在名称前加“/”
2. stringByAppendingPathComponent是路径拼接,会在字符串前自动添加“/”,成为完整路径
两种方法在拼接同一路径时的代码如下:
 NSString *imagePath = [skinPath stringByAppendingString:[NSString stringWithFormat:@"/%@",imageName]];
 NSString *imagePath = [skinPath stringByAppendingPathComponent:imageName];
 NSLog(@"imagePath:%@",imagePath);

相关文章

网友评论

      本文标题:OC - stringByAppendingPathCompon

      本文链接:https://www.haomeiwen.com/subject/trvbdttx.html