我正在处理一些照片资产,我正在尝试浏览我的相机胶卷并打印出每张照片中的所有资产。我知道它需要是一个 for 循环,但只是不完全确定如何编写它
guard let selectedIndexPath = collectionView.indexPathsForSelectedItems?.first else { return nil }
let sectionType = sections[selectedIndexPath.section]
let item = selectedIndexPath.item
let assets: PHFetchResult<PHAsset>
let title: String
switch sectionType {
case .all:
assets = allPhotos
title = AlbumCollectionSectionType.all.description
case .smartAlbums, .userCollections:
let album =
sectionType == .smartAlbums ? smartAlbums[item] : userCollections[item]
assets = PHAsset.fetchAssets(in: album, options: nil)
title = album.localizedTitle ?? ""
}
print("\(assets)")
print("\(assets.object(at: 0))")
return PhotosCollectionViewController(assets: assets, title: title, coder: coder)'