@@ -22,7 +22,7 @@ class AppConfig: ObservableObject {
2222  @Published   var  colorScheme :  ColorScheme 
2323
2424  init ( )  { 
25-     let  value  =  RemoteConfig . remoteConfig ( ) [ " color_scheme " ] . stringValue
25+     let  value  =  RemoteConfig . remoteConfig ( ) [ " color_scheme " ] . stringValue  ??   " " 
2626    colorScheme =  ColorScheme ( value) 
2727    #if !targetEnvironment(macCatalyst) && DEBUG 
2828      NotificationCenter . default. addObserver ( self , 
@@ -38,13 +38,13 @@ class AppConfig: ObservableObject {
3838
3939  func  updateFromRemoteConfig( )  { 
4040    let  remoteConfig  =  RemoteConfig . remoteConfig ( ) 
41-     let  oldValue  =  remoteConfig [ " color_scheme " ] . stringValue
41+     let  oldValue  =  remoteConfig [ " color_scheme " ] . stringValue  ??   " " 
4242    remoteConfig. fetchAndActivate  {  status,  error in 
4343      print ( " Fetch-and-activate completed with status:  \( status. debugDescription) " ) 
4444      if  let  error =  error { 
4545        print ( " Error fetching and activating config:  \( error) " ) 
4646      }  else  { 
47-         let  newValue  =  remoteConfig [ " color_scheme " ] . stringValue
47+         let  newValue  =  remoteConfig [ " color_scheme " ] . stringValue  ??   " " 
4848        if  newValue !=  oldValue { 
4949          print ( " Remote Config changed to:  \( newValue) " ) 
5050          DispatchQueue . main. async   {  self . colorScheme =  ColorScheme ( newValue)  } 
@@ -59,11 +59,11 @@ class AppConfig: ObservableObject {
5959    @available ( iOS 15 ,  tvOS 15 ,  macOS 12 ,  watchOS 8 ,  * )  
6060    func  updateFromRemoteConfigAsync( )  async  { 
6161      let  remoteConfig  =  RemoteConfig . remoteConfig ( ) 
62-       let  oldValue  =  remoteConfig [ " color_scheme " ] . stringValue
62+       let  oldValue  =  remoteConfig [ " color_scheme " ] . stringValue  ??   " " 
6363      do  { 
6464        let  status  =  try   await  remoteConfig. fetchAndActivate ( ) 
6565        print ( " Fetch-and-activate completed with status:  \( status. debugDescription) " ) 
66-         let  newValue  =  remoteConfig [ " color_scheme " ] . stringValue
66+         let  newValue  =  remoteConfig [ " color_scheme " ] . stringValue  ??   " " 
6767        if  newValue !=  oldValue { 
6868          print ( " Remote Config changed to:  \( newValue) " ) 
6969          Task . detached  {  @MainActor   in  self . colorScheme =  ColorScheme ( newValue)  } 
0 commit comments