AFNetworking a-t-il un support de background?
Je suis en train d'enquêter sur AFNetworking en remplacement de ASIHTTPRequest, et je remarque un manque total d'informations sur la prise en charge des téléchargements/Téléchargements en arrière-plan.
Avec ASIHTTPReqeust objet, tout ce que vous avez à faire est d'appeler [request setShouldContinueWhenAppEntersBackground:YES] et la demande continuera en arrière-plan. Y a-t-il un support pour cela dans AFNetworking?
1 réponses
EDIT : à partir de  AFNetworking 1. 0RC1 , c'est une fonctionnalité explicite. AFURLConnectionOperation a maintenant la méthode setShouldExecuteAsBackgroundTaskWithExpirationHandler:, qui gère de manière transparente tout cela pour vous.
c'est une caractéristique implicite, donc je n'ai pas vraiment pensé à la publicité. Tout vous devez faire est:
- (void)applicationWillResignActive:(UIApplication *)application {
    __block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^(void) {
        [application endBackgroundTask:backgroundTaskIdentifier];
        [[YourRestClient sharedClient] cancelAllHTTPOperations];
    }];
}
Ou, si vous gérez vos activités dans votre propre NSOperationQueue, juste -cancelAllOperations ici à la place.