-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added throws to mock logic instead of fatalError
- Loading branch information
Showing
2 changed files
with
21 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import Foundation | ||
|
||
extension Dictionary { | ||
public extension Dictionary { | ||
mutating func update(other: Dictionary) { | ||
for (key, value) in other { | ||
self.updateValue(value, forKey: key) | ||
} | ||
} | ||
} | ||
|
||
public extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any { | ||
func toJSONString() -> String? { | ||
guard let data = try? JSONSerialization.data(withJSONObject: self, options: []), | ||
let json = NSString(data: data as Data, encoding: String.Encoding.utf8.rawValue) else { | ||
return nil | ||
} | ||
return json as String | ||
} | ||
} |