Skip to content

Commit

Permalink
Revert weak authorizeURLHandler. Add method weak() function to se…
Browse files Browse the repository at this point in the history
…t weak explicitely #526 #522
  • Loading branch information
phimage committed Jun 10, 2019
1 parent f8aede8 commit 868b06c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion OAuthSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'OAuthSwift'
s.version = '1.4.0'
s.version = '1.4.1'
s.license = 'MIT'
s.summary = 'Swift based OAuth library for iOS and macOS.'
s.homepage = 'https://github.com/OAuthSwift/OAuthSwift'
Expand Down
14 changes: 1 addition & 13 deletions Sources/OAuthSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@ open class OAuthSwift: NSObject, OAuthSwiftRequestHandle {
open var version: OAuthSwiftCredential.Version { return self.client.credential.version }

/// Handle the authorize url into a web view or browser
open var authorizeURLHandler: OAuthSwiftURLHandlerType {
get {
if let proxy = _authorizeURLHandler as? OAuthSwiftURLHandlerProxy {
return proxy.proxiable ?? _authorizeURLHandler
}
return _authorizeURLHandler
}
set {
_authorizeURLHandler = OAuthSwiftURLHandlerProxy(newValue)
}
}

var _authorizeURLHandler: OAuthSwiftURLHandlerType = OAuthSwiftOpenURLExternally.sharedInstance
open var authorizeURLHandler: OAuthSwiftURLHandlerType = OAuthSwiftOpenURLExternally.sharedInstance

fileprivate var currentRequests: [String: OAuthSwiftRequestHandle] = [:]

Expand Down
13 changes: 10 additions & 3 deletions Sources/OAuthSwiftURLHandlerType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,19 @@ open class ExtensionContextURLHandler: OAuthSwiftURLHandlerType {
}

// MARK: Proxy
class OAuthSwiftURLHandlerProxy: OAuthSwiftURLHandlerType {
open class OAuthSwiftURLHandlerProxy: OAuthSwiftURLHandlerType {
weak var proxiable: OAuthSwiftURLHandlerType?
init(_ proxiable: OAuthSwiftURLHandlerType) {
public init(_ proxiable: OAuthSwiftURLHandlerType) {
self.proxiable = proxiable
}
func handle(_ url: URL) {
open func handle(_ url: URL) {
proxiable?.handle(url)
}
}

extension OAuthSwiftURLHandlerType {

public func weak() -> OAuthSwiftURLHandlerType {
return OAuthSwiftURLHandlerProxy(self)
}
}

0 comments on commit 868b06c

Please sign in to comment.