You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  | //  Copyright (c) 2018 Open Whisper Systems. All rights reserved. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import Foundation | 
					
						
							|  |  |  | import SignalCoreKit | 
					
						
							|  |  |  | import SessionUtilitiesKit | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public class SwiftSingletons: NSObject { | 
					
						
							|  |  |  |     public static let shared = SwiftSingletons() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private var classSet = Set<String>() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private override init() { | 
					
						
							|  |  |  |         super.init() | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public func register(_ singleton: AnyObject) { | 
					
						
							|  |  |  |         guard !SNUtilitiesKit.isRunningTests else { return } | 
					
						
							|  |  |  |         guard _isDebugAssertConfiguration() else { return } | 
					
						
							|  |  |  |         let singletonClassName = String(describing: type(of: singleton)) | 
					
						
							|  |  |  |         guard !classSet.contains(singletonClassName) else { | 
					
						
							|  |  |  |             owsFailDebug("Duplicate singleton: \(singletonClassName).") | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         Logger.verbose("Registering singleton: \(singletonClassName).") | 
					
						
							|  |  |  |         classSet.insert(singletonClassName) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public static func register(_ singleton: AnyObject) { | 
					
						
							|  |  |  |         shared.register(singleton) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |