Skip to content

Commit

Permalink
Merge pull request #138 from rising-jun/feat-homecellimage
Browse files Browse the repository at this point in the history
refactor - 옵셔널바인딩 처리. #135
  • Loading branch information
rising-jun committed Apr 27, 2022
2 parents 9927984 + 8c0bb52 commit 2c0d1f1
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension MockProductRepository: ProductRepository{
var imageData: [DishCategory : [Data]] = [:]
let group = DispatchGroup()
for product in products{
guard let index = dishes[product.category]?.firstIndex(where: { factor in
guard let index: Int = dishes[product.category]?.firstIndex(where: { factor in
if factor.id == product.id{
return true
}
Expand All @@ -41,7 +41,7 @@ extension MockProductRepository: ProductRepository{
guard let count = self.dishes[product.category]?.count else { return }
imageData[product.category] = [Data](repeating: Data(), count: count)
}
imageData[product.category]?[Int(exactly: index)!] = data
imageData[product.category]?[index] = data
group.leave()
}.resume()
}
Expand All @@ -65,11 +65,8 @@ extension MockProductRepository: ProductRepository{
completion(.success(dishes))
}


func fetchList(by category: DishCategory, completion: @escaping (Result<[Product], ProductRepositoryError>) -> Void){
let filteredResults = self.products.filter{ $0.category == category }
completion(.success(filteredResults))
}


}

0 comments on commit 2c0d1f1

Please sign in to comment.