3
votes
for number in 0..<fetchResult.count{
    imgManager.requestImage(for: fetchResult.objects(at: number) as! PHAsset, targetSize: CGSize(width:200, height:200), contentMode: .aspectFill, options: requestOptions, resultHandler: {
    image, error in
        self.imageArray.append(image!)
    })
}

I have following error with number in fetchResult.objects(at:number)

cannot convert value of type 'Int' to expected argument type 'IndexSet'

How can I solve this problem?

1
What is the type of fetchResult - Nirav D
@NiravD let fetchResult : PHFetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions) - kimpro
@kimpro You need to access fetchResult.object(at: number) or subscript with index instead of objects(at:). - Nirav D
@NiravD you saved me! thank you! - kimpro
@kimpro Welcome mate :) - Nirav D

1 Answers

0
votes
for number in fetchResult{
    imgManager.requestImage(for: number as! PHAsset, targetSize: CGSize(width:200, height:200), contentMode: .aspectFill, options: requestOptions, resultHandler: {
    image, error in
        self.imageArray.append(image!)
    })
}