Код: Выделить всё
init() {
PHPhotoLibrary.requestAuthorization { (status) in
switch status {
case .authorized, .limited:
self.errorString = ""
self.getAllPhotos()
case .denied, .restricted:
self.errorString = "Photo access permission denied"
case .notDetermined:
self.errorString = "Photo access permission not determined"
@unknown default:
fatalError()
}
}
updatePhotos()
}
fileprivate func getAllPhotos() {
let manager = PHImageManager.default()
let requestOptions = PHImageRequestOptions()
requestOptions.isSynchronous = false
requestOptions.deliveryMode = .highQualityFormat
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
let results: PHFetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions)
if results.count > 0 {
for i in 0..
Подробнее здесь: [url]https://stackoverflow.com/questions/78170018/ios-app-randomly-crashing-pointing-to-thread-pthread-wqthread[/url]