Remove a number of uses of forEach.

This commit is contained in:
Brent Simmons
2024-11-17 22:08:44 -08:00
parent 16d8b0066e
commit c1c4c8b1b6
14 changed files with 45 additions and 32 deletions

View File

@@ -802,9 +802,9 @@ private extension FeedViewController {
}
func applyToAvailableCells(_ completion: (FeedTableViewCell, 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! FeedTableViewCell, indexPath)
}

View File

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

View File

@@ -452,9 +452,9 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
guard let feed = note.userInfo?[UserInfoKey.feed] as? Feed else {
return
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
for indexPath in tableView.indexPathsForVisibleRows? {
guard let article = dataSource.itemIdentifier(for: indexPath) else {
return
continue
}
if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? TimelineTableViewCell, let image = iconImageFor(article) {
cell.setIconImage(image)
@@ -466,9 +466,9 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
guard coordinator.showIcons, let avatarURL = note.userInfo?[UserInfoKey.url] as? String else {
return
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
for indexPath in tableView.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? TimelineTableViewCell, let image = iconImageFor(article) {

View File

@@ -13,7 +13,9 @@ extension Array where Element == CGRect {
func maxY() -> CGFloat {
var y: CGFloat = 0.0
self.forEach { y = Swift.max(y, $0.maxY) }
for oneRect in self {
y = Swift.max(y, oneRect.maxY)
}
return y
}

View File

@@ -12,10 +12,9 @@ class RoundedProgressView: UIProgressView {
override func layoutSubviews() {
super.layoutSubviews()
subviews.forEach { subview in
for subview in subviews {
subview.layer.masksToBounds = true
subview.layer.cornerRadius = bounds.height / 2.0
}
}
}