mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			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.
		
		
		
		
		
			
		
			
				
	
	
		
			98 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			98 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Swift
		
	
| import Foundation
 | |
| 
 | |
| public protocol UserDefaultsType: AnyObject {
 | |
|     func object(forKey defaultName: String) -> Any?
 | |
|     func string(forKey defaultName: String) -> String?
 | |
|     func array(forKey defaultName: String) -> [Any]?
 | |
|     func dictionary(forKey defaultName: String) -> [String : Any]?
 | |
|     func data(forKey defaultName: String) -> Data?
 | |
|     func stringArray(forKey defaultName: String) -> [String]?
 | |
|     func integer(forKey defaultName: String) -> Int
 | |
|     func float(forKey defaultName: String) -> Float
 | |
|     func double(forKey defaultName: String) -> Double
 | |
|     func bool(forKey defaultName: String) -> Bool
 | |
|     func url(forKey defaultName: String) -> URL?
 | |
| 
 | |
|     func set(_ value: Any?, forKey defaultName: String)
 | |
|     func set(_ value: Int, forKey defaultName: String)
 | |
|     func set(_ value: Float, forKey defaultName: String)
 | |
|     func set(_ value: Double, forKey defaultName: String)
 | |
|     func set(_ value: Bool, forKey defaultName: String)
 | |
|     func set(_ url: URL?, forKey defaultName: String)
 | |
| }
 | |
| 
 | |
| extension UserDefaults: UserDefaultsType {}
 | |
| 
 | |
| public enum SNUserDefaults {
 | |
|     
 | |
|     public enum Bool: Swift.String {
 | |
|         case hasSyncedInitialConfiguration = "hasSyncedConfiguration"
 | |
|         case hasSeenLinkPreviewSuggestion
 | |
|         case hasSeenCallIPExposureWarning
 | |
|         case hasSeenCallMissedTips
 | |
|         case isUsingFullAPNs
 | |
|         case wasUnlinked
 | |
|         case isMainAppActive
 | |
|         case isCallOngoing
 | |
|     }
 | |
| 
 | |
|     public enum Date: Swift.String {
 | |
|         case lastProfilePictureUpload
 | |
|         case lastOpenGroupImageUpdate
 | |
|         case lastOpen
 | |
|         case lastGarbageCollection
 | |
|         case lastPushNotificationSync
 | |
|         case lastCallPreOffer
 | |
|     }
 | |
| 
 | |
|     public enum Double: Swift.String {
 | |
|         case lastDeviceTokenUpload = "lastDeviceTokenUploadTime"
 | |
|     }
 | |
| 
 | |
|     public enum Int: Swift.String {
 | |
|         case appMode
 | |
|         case hardfork
 | |
|         case softfork
 | |
|     }
 | |
|     
 | |
|     public enum String : Swift.String {
 | |
|         case deviceToken
 | |
|         case topBannerWarningToShow
 | |
|     }
 | |
| }
 | |
| 
 | |
| public extension UserDefaults {
 | |
|     static let applicationGroup: String = "group.com.loki-project.loki-messenger"
 | |
|     
 | |
|     @objc static var sharedLokiProject: UserDefaults? {
 | |
|         UserDefaults(suiteName: UserDefaults.applicationGroup)
 | |
|     }
 | |
| }
 | |
| 
 | |
| public extension UserDefaultsType {
 | |
|     subscript(bool: SNUserDefaults.Bool) -> Bool {
 | |
|         get { return self.bool(forKey: bool.rawValue) }
 | |
|         set { set(newValue, forKey: bool.rawValue) }
 | |
|     }
 | |
| 
 | |
|     subscript(date: SNUserDefaults.Date) -> Date? {
 | |
|         get { return self.object(forKey: date.rawValue) as? Date }
 | |
|         set { set(newValue, forKey: date.rawValue) }
 | |
|     }
 | |
|     
 | |
|     subscript(double: SNUserDefaults.Double) -> Double {
 | |
|         get { return self.double(forKey: double.rawValue) }
 | |
|         set { set(newValue, forKey: double.rawValue) }
 | |
|     }
 | |
| 
 | |
|     subscript(int: SNUserDefaults.Int) -> Int {
 | |
|         get { return self.integer(forKey: int.rawValue) }
 | |
|         set { set(newValue, forKey: int.rawValue) }
 | |
|     }
 | |
|     
 | |
|     subscript(string: SNUserDefaults.String) -> String? {
 | |
|         get { return self.string(forKey: string.rawValue) }
 | |
|         set { set(newValue, forKey: string.rawValue) }
 | |
|     }
 | |
| }
 |