Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Removing force unwrapping of Data
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Jun 30, 2017
1 parent 6b22682 commit fdc3dc5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Code/NetworkManager.swift
Expand Up @@ -288,7 +288,7 @@ open class NetworkManager : NSObject {
switch deserializer {
case let .jsonResponse(f):
if let data = data,
let raw : AnyObject = try! JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as AnyObject?
let raw : AnyObject = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as AnyObject
{
let json = JSON(raw)
let result = interceptors.reduce(.success(json)) {(current : Result<JSON>, interceptor : @escaping (_ _response : HTTPURLResponse, _ _json : JSON) -> Result<JSON>) -> Result<JSON> in
Expand All @@ -306,7 +306,7 @@ open class NetworkManager : NSObject {
case let .noContent(f):
if response.hasErrorResponseCode() { // server error
guard let data = data,
let raw : AnyObject = try! JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as AnyObject? else {
let raw : AnyObject = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as AnyObject else {
return .failure(error)
}
let userInfo = JSON(raw).object as? [AnyHashable: Any]
Expand Down

0 comments on commit fdc3dc5

Please sign in to comment.