Skip to content

Commit

Permalink
Add @objc annotation to ScreenShotObserverDelegate (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Econa77 authored May 20, 2020
1 parent 612c408 commit a4d25f5
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Lib/Screeen/ScreenShotObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) }
}
}
}
Expand Down

0 comments on commit a4d25f5

Please sign in to comment.