Replace uses of forEach with for-in loops.

This commit is contained in:
Brent Simmons
2023-07-09 22:14:09 -07:00
parent 090e63b017
commit abb11afe3d
6 changed files with 43 additions and 35 deletions

View File

@@ -879,9 +879,9 @@ private extension MasterFeedViewController {
}
func applyToAvailableCells(_ completion: (MasterFeedTableViewCell, IndexPath) -> Void) {
tableView.visibleCells.forEach { cell in
for cell in tableView.visibleCells {
guard let indexPath = tableView.indexPath(for: cell) else {
return
continue
}
completion(cell as! MasterFeedTableViewCell, indexPath)
}

View File

@@ -476,9 +476,12 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
guard let feed = note.userInfo?[UserInfoKey.feed] as? Feed else {
return
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
guard let indexPathsForVisibleRows = tableView.indexPathsForVisibleRows else {
return
}
for indexPath in indexPathsForVisibleRows {
guard let article = dataSource.itemIdentifier(for: indexPath) else {
return
continue
}
if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = iconImageFor(article) {
cell.setIconImage(image)
@@ -490,9 +493,12 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
guard coordinator.showIcons, let avatarURL = note.userInfo?[UserInfoKey.url] as? String else {
return
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
guard let indexPathsForVisibleRows = tableView.indexPathsForVisibleRows else {
return
}
for indexPath in indexPathsForVisibleRows {
guard let article = dataSource.itemIdentifier(for: indexPath), let authors = article.authors, !authors.isEmpty else {
return
continue
}
for author in authors {
if author.avatarURL == avatarURL, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = iconImageFor(article) {

View File

@@ -1468,7 +1468,7 @@ private extension SceneCoordinator {
func rebuildArticleDictionaries() {
var idDictionary = [String: Article]()
articles.forEach { article in
for article in articles {
idDictionary[article.articleID] = article
}