@@ -57,22 +57,22 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
5757 }
5858
5959 let responseString = responseObject. description as NSString
60- let services = responseDict. forKey ( ServiceDictionaryKeys . services) as NSDictionary
60+ let services : NSDictionary = ( responseDict. forKey ( ServiceDictionaryKeys . services) as? NSDictionary ) ?? NSDictionary ( )
6161
6262 let publicizeServices : [ RemotePublicizeService ] = services. allKeys. map { ( key) -> RemotePublicizeService in
63- let dict = services. forKey ( key) as NSDictionary
63+ let dict = ( services. forKey ( key) as? NSDictionary ) ?? NSDictionary ( )
6464 let pub = RemotePublicizeService ( )
6565
66- pub. connectURL = dict. string ( forKey: ServiceDictionaryKeys . connectURL)
67- pub. detail = dict. string ( forKey: ServiceDictionaryKeys . description)
68- pub. externalUsersOnly = dict. number ( forKey: ServiceDictionaryKeys . externalUsersOnly) . boolValue
69- pub. icon = dict. string ( forKey: ServiceDictionaryKeys . icon)
70- pub. serviceID = dict. string ( forKey: ServiceDictionaryKeys . ID)
71- pub. jetpackModuleRequired = dict. string ( forKey: ServiceDictionaryKeys . jetpackModuleRequired)
72- pub. jetpackSupport = dict. number ( forKey: ServiceDictionaryKeys . jetpackSupport) . boolValue
73- pub. label = dict. string ( forKey: ServiceDictionaryKeys . label)
74- pub. multipleExternalUserIDSupport = dict. number ( forKey: ServiceDictionaryKeys . multipleExternalUserIDSupport) . boolValue
75- pub. type = dict. string ( forKey: ServiceDictionaryKeys . type)
66+ pub. connectURL = dict. string ( forKey: ServiceDictionaryKeys . connectURL) ?? " "
67+ pub. detail = dict. string ( forKey: ServiceDictionaryKeys . description) ?? " "
68+ pub. externalUsersOnly = dict. number ( forKey: ServiceDictionaryKeys . externalUsersOnly) ? . boolValue ?? false
69+ pub. icon = dict. string ( forKey: ServiceDictionaryKeys . icon) ?? " "
70+ pub. serviceID = dict. string ( forKey: ServiceDictionaryKeys . ID) ?? " "
71+ pub. jetpackModuleRequired = dict. string ( forKey: ServiceDictionaryKeys . jetpackModuleRequired) ?? " "
72+ pub. jetpackSupport = dict. number ( forKey: ServiceDictionaryKeys . jetpackSupport) ? . boolValue ?? false
73+ pub. label = dict. string ( forKey: ServiceDictionaryKeys . label) ?? " "
74+ pub. multipleExternalUserIDSupport = dict. number ( forKey: ServiceDictionaryKeys . multipleExternalUserIDSupport) ? . boolValue ?? false
75+ pub. type = dict. string ( forKey: ServiceDictionaryKeys . type) ?? " "
7676
7777 // We're not guarenteed to get the right order by inspecting the
7878 // response dictionary's keys. Instead, we can check the index
@@ -112,7 +112,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
112112 return
113113 }
114114
115- let connections : Array = responseDict. array ( forKey: ConnectionDictionaryKeys . connections)
115+ let connections = responseDict. array ( forKey: ConnectionDictionaryKeys . connections) ?? [ ]
116116 let keyringConnections : [ KeyringConnection ] = connections. map { ( dict) -> KeyringConnection in
117117 let conn = KeyringConnection ( )
118118 let dict = dict as AnyObject
@@ -186,7 +186,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
186186 return
187187 }
188188
189- let connections : Array = responseDict. array ( forKey: ConnectionDictionaryKeys . connections)
189+ let connections = responseDict. array ( forKey: ConnectionDictionaryKeys . connections) ?? [ ]
190190 let publicizeConnections : [ RemotePublicizeConnection ] = connections. compactMap { ( dict) -> RemotePublicizeConnection ? in
191191 let conn = self . remotePublicizeConnectionFromDictionary ( dict as! NSDictionary )
192192 return conn
@@ -421,7 +421,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
421421 return
422422 }
423423
424- let buttons = responseDict. array ( forKey: SharingButtonsKeys . sharingButtons) as NSArray
424+ let buttons = responseDict. array ( forKey: SharingButtonsKeys . sharingButtons) as? NSArray ?? NSArray ( )
425425 let sharingButtons = self . remoteSharingButtonsFromDictionary ( buttons)
426426
427427 onSuccess ( sharingButtons)
@@ -457,7 +457,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
457457 return
458458 }
459459
460- let buttons = responseDict. array ( forKey: SharingButtonsKeys . updated) as NSArray
460+ let buttons = responseDict. array ( forKey: SharingButtonsKeys . updated) as? NSArray ?? NSArray ( )
461461 let sharingButtons = self . remoteSharingButtonsFromDictionary ( buttons)
462462
463463 onSuccess ( sharingButtons)
0 commit comments