Load Offline Cached JSON Using Afnetworking

AFNetworking 2.0 and use cache only when offline

You just need to subclass the AFHTTPSessionManager and check if the client is offline. Then you can change the cache policy or force the app to use cached data.

NSURLRequest not caching on disk using AFNetworking

I think the functionality you are wanting here is going to require using core data or writing your own caching using NSFileManager. Figure out the best approach for your app. There is a pretty cool article about NSFileManager by Mattt Thompson here

AFNetworking 2.0 queue request when device is offline with setReachabilityStatusChangeBlock does nothing

You need to call startMonitoring, before you call setReachabilityStatusChangeBlock

[manager.reachabilityManager startMonitoring];

If you are using AFNetworking 2.0, I suggest following:

[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
DLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
switch (status) {
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
[operationQueue setSuspended:NO];
NSLog(@"WIFI");
break;
case AFNetworkReachabilityStatusNotReachable:
default:
[operationQueue setSuspended:YES];
NSLog(@"offline, baby");
break;
}
}];

Pre-cache Images for AFNetworking's UIImageView category

Please, please don't do this.

Trust me when I say that this almost certainly unnecessary.

In fact, it will likely have the opposite of the desired effect, due to the increased pressure of downloading images that will probably never be viewed.

The cache is private for a very good reason--it's just there to speed up subsequent requests on scroll views. Just have the table view download the images as requested, and you should be just fine. If anything, you can optimize the size of the images that you are downloading (ensure correct image dimensions; compress intelligently).



Related Topics



Leave a reply



Submit