1.拿到mainBundle下Photos文件夹的路径
NSString *photosDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Photos"];
2.遍历文件夹Photos
NSArray * photosArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:photosDirectory error:nil];
如果Photos里有文件1.png,2.png,3.png . photosArray数组将会是 @[@"1.png", @"2.png", @"3.png"]
3.获得文件的完整路径
NSString *photoName = photosArray[0];
NSString *photoFilePath = [photosDirectory stringByAppendingPathComponent:photoName];
4.获得不带类型后缀的文件名
NSString *photoNameWithoutSuffix= [photoName stringByDeletingPathExtension];
时间: 2024-10-13 07:30:26