I am having trouble with saving JSON to NSCachedURLResponse
.
This is my code:
operation.responseSerializer = AFJSONResponseSerializer()
operation.setCompletionBlockWithSuccess({ (operation, responseObject) -> Void in
var cachedResponse = NSCachedURLResponse(response: operation.response,
data: operation.responseData)
NSURLCache.sharedURLCache().storeCachedResponse(cachedResponse, forRequest: request)
})
I know that this code has no actual error but it's causing a JSON format problem.
By saving operation.response
and operation.responsedata
its causing the JSON to be formatted like "feed":
instead of feed =
.
I've printed the responseObject
which is the JSON before saving it was like feed =
. so my problem with saving the responseObject
into NSCachedURLResponse
with its original formatting.
How can I achieve this?