Skip to content

Commit

Permalink
Fix null probability
Browse files Browse the repository at this point in the history
  • Loading branch information
ialimz committed Sep 25, 2021
1 parent 1df7ead commit e91b5a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/NetShears/NetShears.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class NetShears: NSObject {
let networkRequestInterceptor = NetworkRequestInterceptor()
lazy var config: NetworkInterceptorConfig = {
var savedModifiers = [RequestEvaluatorModifier]().retrieveFromDisk()
return NetworkInterceptorConfig(modifiers: savedModifiers)
return NetworkInterceptorConfig(modifiers: savedModifiers ?? [])
}()


Expand Down
4 changes: 2 additions & 2 deletions Sources/NetShears/Protocols/PersistHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public class PersistHelper {
/// - directory: directory where struct data is stored
/// - type: struct type (i.e. Message.self)
/// - Returns: decoded struct model(s) of data
static func retrieve<T: Decodable>(_ fileName: String, as type: T.Type) -> T {
static func retrieve<T: Decodable>(_ fileName: String, as type: T.Type) -> T? {
let url = getURL().appendingPathComponent(fileName, isDirectory: false)

if !FileManager.default.fileExists(atPath: url.path) {
fatalError("File at path \(url.path) does not exist!")
return nil
}

if let data = FileManager.default.contents(atPath: url.path) {
Expand Down

0 comments on commit e91b5a0

Please sign in to comment.