Skip to content

Commit

Permalink
Merge pull request #70 from heoblitz/etc/refactor_deprecated_function
Browse files Browse the repository at this point in the history
Refactor deprecated unarchiveTopLevelObjectWithData
  • Loading branch information
ekazaev authored Mar 14, 2024
2 parents 81b6af7 + 7965a26 commit c26d49c
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ final class MetaDataCache<Cache: AsyncKeyValueCaching>: AsyncKeyValueCaching whe

func getEntity(for url: URL) throws -> LPLinkMetadata {
let data = try cache.getEntity(for: url)
// swiftlint:disable force_try force_cast
let entity = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! LPLinkMetadata
// swiftlint:enable force_try force_cast
guard let entity = try NSKeyedUnarchiver.unarchivedObject(ofClass: LPLinkMetadata.self, from: data) else {
throw CacheError.invalidData
}
return entity
}

Expand All @@ -50,9 +50,7 @@ final class MetaDataCache<Cache: AsyncKeyValueCaching>: AsyncKeyValueCaching whe
}

func store(entity: LPLinkMetadata, for key: URL) throws {
// swiftlint:disable force_try
let codedData = try! NSKeyedArchiver.archivedData(withRootObject: entity, requiringSecureCoding: true)
// swiftlint:enable force_try
let codedData = try NSKeyedArchiver.archivedData(withRootObject: entity, requiringSecureCoding: true)
try cache.store(entity: codedData, for: key)
}
}
Expand Down

0 comments on commit c26d49c

Please sign in to comment.