diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index b78c6f00e..d1d9bcf36 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -705,9 +705,11 @@ extension AppDelegate { } @IBAction func debugDropConditionalGetInfo(_ sender: Any?) { - #if DEBUG - AccountManager.shared.activeAccounts.forEach{ $0.debugDropConditionalGetInfo() } - #endif +#if DEBUG + for account in AccountManager.shared.activeAccounts { + account.debugDropConditionalGetInfo() + } +#endif } @IBAction func debugTestCrashReporterWindow(_ sender: Any?) { diff --git a/Mac/MainWindow/AddFeed/FolderTreeMenu.swift b/Mac/MainWindow/AddFeed/FolderTreeMenu.swift index 87250dd6b..c9e122769 100644 --- a/Mac/MainWindow/AddFeed/FolderTreeMenu.swift +++ b/Mac/MainWindow/AddFeed/FolderTreeMenu.swift @@ -62,8 +62,8 @@ class FolderTreeMenu { private static func addFolderItemsToMenuWithNodes(menu: NSMenu, nodes: [Node], indentationLevel: Int) { - nodes.forEach { (oneNode) in - + for oneNode in nodes { + if let nameProvider = oneNode.representedObject as? DisplayNameProvider { let menuItem = NSMenuItem(title: nameProvider.nameForDisplay, action: nil, keyEquivalent: "") diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index a07545fa5..81c9ed6a3 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -375,7 +375,7 @@ private extension SidebarOutlineDataSource { return false } - draggedNodes.forEach { node in + for node in draggedNodes { if sameAccount(node, parentNode) { if NSApplication.shared.currentEvent?.modifierFlags.contains(.option) ?? false { copyFeedInAccount(node: node, to: parentNode) @@ -464,7 +464,7 @@ private extension SidebarOutlineDataSource { return false } - draggedNodes.forEach { node in + for node in draggedNodes { if !sameAccount(node, parentNode) { copyFolderBetweenAccounts(node: node, to: parentNode) } diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 81cc354c6..e7160fe36 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -112,8 +112,10 @@ protocol SidebarDelegate: AnyObject { } let selectedFeedIdentifers = Set(selectedFeedsState.compactMap( { SidebarItemIdentifier(userInfo: $0) })) - selectedFeedIdentifers.forEach { treeControllerDelegate.addFilterException($0) } - + for feedIdentifier in selectedFeedIdentifers { + treeControllerDelegate.addFilterException(feedIdentifier) + } + rebuildTreeAndReloadDataIfNeeded() var selectIndexes = IndexSet() @@ -529,7 +531,9 @@ private extension SidebarViewController { } func addAllSelectedToFilterExceptions() { - selectedFeeds.forEach { addToFilterExeptionsIfNecessary($0) } + for feed in selectedFeeds { + addToFilterExeptionsIfNecessary(feed) + } } func addToFilterExeptionsIfNecessary(_ feed: SidebarItem?) { @@ -572,13 +576,12 @@ private extension SidebarViewController { restoreSelection(to: savedSelection, sendNotificationIfChanged: true) // Automatically expand any new or newly active accounts - AccountManager.shared.activeAccounts.forEach { account in + for account in AccountManager.shared.activeAccounts { if !savedAccounts.contains(account) { let accountNode = treeController.nodeInTreeRepresentingObject(account) outlineView.expandItem(accountNode) } } - } func rebuildTreeAndReloadDataIfNeeded() { diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift index df4fb42b2..3c06c1423 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -231,7 +231,9 @@ private extension Array where Element == NSRect { 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 } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index 8a0199f12..0a05787e3 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -208,7 +208,7 @@ private extension TimelineViewController { } let menu = NSMenu(title: NSLocalizedString("Share", comment: "Share menu name")) - services.forEach { (service) in + for service in services { service.delegate = sharingServiceDelegate let menuItem = NSMenuItem(title: service.menuItemTitle, action: #selector(performShareServiceFromContextualMenu(_:)), keyEquivalent: "") menuItem.image = service.image diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index e54e70ab6..a3d29721f 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -1045,7 +1045,7 @@ private extension TimelineViewController { func updateArticleRowMap() { var rowMap = [String: [Int]]() var index = 0 - articles.forEach { (article) in + for article in articles { if var indexes = rowMap[article.articleID] { indexes.append(index) rowMap[article.articleID] = indexes @@ -1066,9 +1066,9 @@ private extension TimelineViewController { func indexesForArticleIDs(_ articleIDs: Set) -> IndexSet { var indexes = IndexSet() - articleIDs.forEach { (articleID) in + for articleID in articleIDs { guard let rowsIndex = rows(for: articleID) else { - return + continue } for rowIndex in rowsIndex { indexes.insert(rowIndex) diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index 1c3fea02e..5de96bb26 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -48,9 +48,9 @@ final class DeleteCommand: UndoableCommand { func perform() { let group = DispatchGroup() - itemSpecifiers.forEach { + for itemSpecifier in itemSpecifiers { group.enter() - $0.delete() { + itemSpecifier.delete() { group.leave() } } @@ -59,11 +59,12 @@ final class DeleteCommand: UndoableCommand { self.treeController?.rebuild() self.registerUndo() } - } func undo() { - itemSpecifiers.forEach { $0.restore() } + for itemSpecifier in itemSpecifiers { + itemSpecifier.restore() + } registerRedo() } diff --git a/Shared/ShareExtension/ExtensionFeedAddRequestFile.swift b/Shared/ShareExtension/ExtensionFeedAddRequestFile.swift index f23038645..2bbb4a6d4 100644 --- a/Shared/ShareExtension/ExtensionFeedAddRequestFile.swift +++ b/Shared/ShareExtension/ExtensionFeedAddRequestFile.swift @@ -127,7 +127,11 @@ private extension ExtensionFeedAddRequestFile { os_log(.error, log: Self.log, "Save to disk coordination failed: %@.", error.localizedDescription) } - requests?.forEach { processRequest($0) } + if let requests { + for request in requests { + processRequest(request) + } + } } func processRequest(_ request: ExtensionFeedAddRequest) { diff --git a/iOS/Feed/FeedViewController.swift b/iOS/Feed/FeedViewController.swift index 0c53df066..86d13a5f0 100644 --- a/iOS/Feed/FeedViewController.swift +++ b/iOS/Feed/FeedViewController.swift @@ -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) } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 1d8049b7d..dce6f3373 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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 } diff --git a/iOS/Timeline/TimelineViewController.swift b/iOS/Timeline/TimelineViewController.swift index a92853357..42e593bb6 100644 --- a/iOS/Timeline/TimelineViewController.swift +++ b/iOS/Timeline/TimelineViewController.swift @@ -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) { diff --git a/iOS/UIKit Extensions/Array-Extensions.swift b/iOS/UIKit Extensions/Array-Extensions.swift index 9a4710680..b280bc450 100644 --- a/iOS/UIKit Extensions/Array-Extensions.swift +++ b/iOS/UIKit Extensions/Array-Extensions.swift @@ -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 } diff --git a/iOS/UIKit Extensions/RoundedProgressView.swift b/iOS/UIKit Extensions/RoundedProgressView.swift index a48aa6bf1..5f892dcbf 100644 --- a/iOS/UIKit Extensions/RoundedProgressView.swift +++ b/iOS/UIKit Extensions/RoundedProgressView.swift @@ -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 } } - }