From a4d25f5d76a00206f9c8e7e0d7bad2c0b37541e5 Mon Sep 17 00:00:00 2001 From: Econa77 Date: Wed, 20 May 2020 23:20:21 +0900 Subject: [PATCH] Add @objc annotation to ScreenShotObserverDelegate (#18) --- Lib/Screeen/ScreenShotObserver.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Lib/Screeen/ScreenShotObserver.swift b/Lib/Screeen/ScreenShotObserver.swift index 17d28b1..10311ee 100644 --- a/Lib/Screeen/ScreenShotObserver.swift +++ b/Lib/Screeen/ScreenShotObserver.swift @@ -10,16 +10,11 @@ import Foundation +@objc public protocol ScreenShotObserverDelegate: AnyObject { - func screenShotObserver(_ observer: ScreenShotObserver, addedItem item: NSMetadataItem) - func screenShotObserver(_ observer: ScreenShotObserver, updatedItem item: NSMetadataItem) - func screenShotObserver(_ observer: ScreenShotObserver, removedItem item: NSMetadataItem) -} - -public extension ScreenShotObserverDelegate { - func screenShotObserver(_ observer: ScreenShotObserver, addedItem item: NSMetadataItem) {} - func screenShotObserver(_ observer: ScreenShotObserver, updatedItem item: NSMetadataItem) {} - func screenShotObserver(_ observer: ScreenShotObserver, removedItem item: NSMetadataItem) {} + @objc optional func screenShotObserver(_ observer: ScreenShotObserver, addedItem item: NSMetadataItem) + @objc optional func screenShotObserver(_ observer: ScreenShotObserver, updatedItem item: NSMetadataItem) + @objc optional func screenShotObserver(_ observer: ScreenShotObserver, removedItem item: NSMetadataItem) } public final class ScreenShotObserver: NSObject { @@ -77,11 +72,11 @@ public final class ScreenShotObserver: NSObject { guard isEnabled else { return } if let items = notification.userInfo?[kMDQueryUpdateAddedItems as String] as? [NSMetadataItem] { - items.forEach { delegate?.screenShotObserver(self, addedItem: $0) } + items.forEach { delegate?.screenShotObserver?(self, addedItem: $0) } } else if let items = notification.userInfo?[kMDQueryUpdateChangedItems as String] as? [NSMetadataItem] { - items.forEach { delegate?.screenShotObserver(self, updatedItem: $0) } + items.forEach { delegate?.screenShotObserver?(self, updatedItem: $0) } } else if let items = notification.userInfo?[kMDQueryUpdateRemovedItems as String] as? [NSMetadataItem] { - items.forEach { delegate?.screenShotObserver(self, removedItem: $0) } + items.forEach { delegate?.screenShotObserver?(self, removedItem: $0) } } } }