【发布时间】:2016-01-31 23:21:39
【问题描述】:
我正在尝试仅从设备相册中提取实况照片。 我找到了这个 Objective C 代码,但由于某种原因,将其转换为 Swift 时无法编译。
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.predicate = [NSPredicate predicateWithFormat: @"(mediaSubtype == %ld)", PHAssetMediaSubtypePhotoLive];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey: @"creationDate" ascending: NO]];
PHFetchResult<PHAsset *> *assetsFetchResults = [PHAsset fetchAssetsWithMediaType: PHAssetMediaTypeImage options: options];
斯威夫特:
fetchOptions.predicate = NSPredicate(format: "mediaSubtype == %ld", PHAssetMediaSubtype.PhotoLive)
抛出编译错误:
Argument type 'PHAssetMediaSubtype' does not conform to expected type 'CVarArgType'
Any suggestions?
【问题讨论】:
标签: ios swift nspredicate photosframework phasset