Created
July 12, 2019 05:22
-
-
Save shotastage/ac1454cb5b46663974607e09692b8b06 to your computer and use it in GitHub Desktop.
Singleton + Delegattion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class StoreObject { | |
/// Shared Instance | |
static let shared = StoreObject() | |
weak var delegate : StoreObjectDelegate? | |
var value: Int = 0 { | |
didSet { | |
self.notifyToDelegate() | |
} | |
} | |
/// Constructor | |
private init() { } | |
private func notifyToDelegate() { | |
self.delegate?.didUpdatedValue() | |
} | |
} | |
/// GeoLocation Service delegate | |
protocol StoreObjectDelegate: class { | |
func didUpdatedValue() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment