I've implemented AFNetworking
without subclassing AFHTTPClient
, in part using the following code in my DownloadQueueManager
:
-(void)downloadPodcastAt:(NSString *)url toPath:(NSString *)path
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:60.0];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
[self saveQueuedItemInformation];
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
// Other stuff
}];
[operation start];
}
My question is manifold. I've googled til' my fingers went numb, and have yet to find a decent code sample that simply and easily checks for Reachability status using AFNetworking
. (Oddly, there is plenty of discussion about importing SystemConfiguration.framework
, which seems like a no-brainer). So if my user wants to minimize their data usage, and only download using wifi, how do I check for wifi, and only download if wifi is available?
Second, it seems like AFNetworking
wants to be a user-friendly front-end. But I could actually use a front-end to this front-end, because there's a LOT of stuff in there that one has to weed through to get to the stuff one needs. I just need to access a url, download an xml file (based on reachability), and do stuff with it. Am I missing something that makes this a simple task ?
When I make sense of this, I'm totally building a front-end or five to simplify implementation (assuming I'm not just an idiot). Thanks in advance for any responses.
Reachability
isn't part of AFNetworking, you'll have to rely either on it's notification or do a status-check manually. It makes sense as you might want to check connectivity before the user is even able to try loading something, and networking operations could use cache or return an error. – Beaudoin