@@ -17,11 +17,13 @@ import Foundation
1717 @_exported import FirebaseRemoteConfigInternal
1818#endif // SWIFT_PACKAGE
1919
20- // TODO: Document.
20+ /// Represents a value associated with a key in a custom signal, restricted to the allowed data
21+ /// types : String, Int, Double.
2122public struct CustomSignalValue {
2223 private enum Kind {
2324 case string( String )
2425 case integer( Int )
26+ case double( Double )
2527 }
2628
2729 private let kind : Kind
@@ -44,12 +46,21 @@ public struct CustomSignalValue {
4446 Self ( kind: . integer( integer) )
4547 }
4648
49+ /// Returns an floating-point backed custom signal.
50+ /// - Parameter double: The given floating-point value to back the custom signal with.
51+ /// - Returns: An floating-point backed custom signal
52+ public static func double( _ double: Double ) -> Self {
53+ Self ( kind: . double( double) )
54+ }
55+
4756 fileprivate func toNSObject( ) -> NSObject {
4857 switch kind {
4958 case let . string( string) :
5059 return string as NSString
5160 case let . integer( int) :
5261 return int as NSNumber
62+ case let . double( double) :
63+ return double as NSNumber
5364 }
5465 }
5566}
@@ -66,6 +77,12 @@ extension CustomSignalValue: ExpressibleByIntegerLiteral {
6677 }
6778}
6879
80+ extension CustomSignalValue : ExpressibleByFloatLiteral {
81+ public init ( floatLiteral value: Double ) {
82+ self = . double( value)
83+ }
84+ }
85+
6986@available ( iOS 13 , tvOS 13 , macOS 10 . 15 , macCatalyst 13 , watchOS 7 , * )
7087public extension RemoteConfig {
7188 /// Sets custom signals for this Remote Config instance.
0 commit comments