我无法将 JSON 保存到NSCachedURLResponse
.
这是我的代码:
operation.responseSerializer = AFJSONResponseSerializer()
operation.setCompletionBlockWithSuccess({ (operation, responseObject) -> Void in
var cachedResponse = NSCachedURLResponse(response: operation.response,
data: operation.responseData)
NSURLCache.sharedURLCache().storeCachedResponse(cachedResponse, forRequest: request)
})
我知道这段代码没有实际错误,但它会导致 JSON 格式问题。通过保存operation.response
并operation.responsedata
导致 JSON 被格式化,"feed":
而不是feed =
.
在保存它之前,我已经打印了responseObject
哪个是 JSON,就像feed =
. 所以我用原始格式保存responseObject
到的问题。NSCachedURLResponse
我怎样才能做到这一点?