From 932006e1b908bd362ea38078c3a0147e48434c6a Mon Sep 17 00:00:00 2001 From: Ste Prescott Date: Sun, 14 Jun 2020 17:27:23 +0100 Subject: [PATCH] Change delegate calls to return sharable --- Sources/Share/Share.swift | 6 +++--- Sources/Share/Sheet.swift | 14 +++++++------- Tests/ShareTests/ShareTests.swift | 7 +------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Sources/Share/Share.swift b/Sources/Share/Share.swift index d6c563a..f52fe8c 100644 --- a/Sources/Share/Share.swift +++ b/Sources/Share/Share.swift @@ -24,9 +24,9 @@ extension Share { extension Share.Service { public enum Status { - case willShare([Any], via: Share.Service) - case didShare([Any], via: Share.Service) - case error(Share.Service.Status.Error, sharing:[Any]) + case willShare(Sharable, via: Share.Service) + case didShare(Sharable, via: Share.Service) + case error(Share.Service.Status.Error, sharing: Sharable) } } diff --git a/Sources/Share/Sheet.swift b/Sources/Share/Sheet.swift index b27b7fa..2a545d2 100644 --- a/Sources/Share/Sheet.swift +++ b/Sources/Share/Sheet.swift @@ -19,7 +19,7 @@ extension Share { guard service == nil else { return } - serviceDelegate?.didChange(status: .error(.cancelled(service), sharing: sharable.shareItems)) + serviceDelegate?.didChange(status: .error(.cancelled(service), sharing: sharable)) } public func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> NSSharingServiceDelegate? { @@ -29,15 +29,15 @@ extension Share { // MARK:- NSSharingServiceDelegate public func sharingService(_ sharingService: NSSharingService, willShareItems items: [Any]) { - serviceDelegate?.didChange(status: .willShare(items, via: sharingService)) + serviceDelegate?.didChange(status: .willShare(sharable, via: sharingService)) } public func sharingService(_ sharingService: NSSharingService, didShareItems items: [Any]) { - serviceDelegate?.didChange(status: .didShare(items, via: sharingService)) + serviceDelegate?.didChange(status: .didShare(sharable, via: sharingService)) } public func sharingService(_ sharingService: NSSharingService, didFailToShareItems items: [Any], error: Error) { - serviceDelegate?.didChange(status: .error(.other(error, with: sharingService), sharing: items)) + serviceDelegate?.didChange(status: .error(.other(error, with: sharingService), sharing: sharable)) } } } @@ -66,9 +66,9 @@ extension Share { } if !completed { - self.report(.willShare(sharable.shareItems, via: service)) + self.report(.willShare(sharable, via: service)) } else { - self.report(.didShare(sharable.shareItems, via: service)) + self.report(.didShare(sharable, via: service)) } } } @@ -78,7 +78,7 @@ extension Share { } private func report(error: Share.Service.Status.Error) { - serviceDelegate?.didChange(status: .error(error, sharing: sharable.shareItems)) + serviceDelegate?.didChange(status: .error(error, sharing: sharable)) } } } diff --git a/Tests/ShareTests/ShareTests.swift b/Tests/ShareTests/ShareTests.swift index ba01af3..4216ce8 100644 --- a/Tests/ShareTests/ShareTests.swift +++ b/Tests/ShareTests/ShareTests.swift @@ -2,12 +2,7 @@ import XCTest @testable import Share final class ShareTests: XCTestCase { - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - XCTAssertEqual(Share().text, "Hello, World!") - } + func testExample() { } static var allTests = [ ("testExample", testExample),