From f0dc1236bf51cebe8ec2105e75ee1eb6eb05c9af Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Sun, 18 Nov 2018 20:40:58 +0100 Subject: [PATCH] Refactors logCopyToClipboardClick --- .../Controllers/PreferencesWindowController.swift | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift index b0fe720e..9a54fe79 100644 --- a/Aerial/Source/Controllers/PreferencesWindowController.swift +++ b/Aerial/Source/Controllers/PreferencesWindowController.swift @@ -1297,18 +1297,10 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo } @IBAction func logCopyToClipboardClick(_ sender: NSButton) { - guard !errorMessages.isEmpty else { - return - } + guard !errorMessages.isEmpty else { return } - let dateFormatter = DateFormatter() - dateFormatter.dateStyle = .none - dateFormatter.timeStyle = .medium - - var clipboard = "" - for log in errorMessages { - clipboard += dateFormatter.string(from: log.date) + " : " + log.message + "\n" - } + let clipboard = errorMessages.map { dateFormatter.string(from: $0.date) + " : " + $0.message} + .joined(separator: "\n") let pasteBoard = NSPasteboard.general pasteBoard.clearContents()