Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

iOS Multitasking support #126

Closed
wants to merge 54 commits into from
Closed

iOS Multitasking support #126

wants to merge 54 commits into from

Conversation

zbowling
Copy link

We added support for iOS multitasking in our branch. It's completely optional by setting requestOperation.attemptToContinueWhenAppEntersBackground = YES;

Commit seatme/AFNetworking@d56f873bc has most of the changes. This is a little more tricky of a patch to integrate upstream because it's dependent on the changes we made to handle success/failure callbacks but in your model, you could solve this possibly in the base version of setCompletionBlockWithSuccessBlock:FailureBlock concept (actually I don't know if this is in base class like us but it could be).

Originally we did this at the AFURLRequestOperation level but we moved it up to the AFHTTPRequestOperation level because we want to make sure that the the task is ended after the success and failure callbacks have returned to give the caller a chance to something before allowing the app to shut down. You could move it back down to AFURLRequstionOperation by handling the endBackgroundTask call in the completionBlock but that may not work in your model since you should really end the task after the dispatched async callback for the success and failure blocks so they have a chance to run.

Either way. Interesting changes I wanted share upstream.

zbowling and others added 30 commits September 22, 2011 16:16
Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFHTTPRequestOperation.m
	AFNetworking/AFJSONRequestOperation.m
	AFNetworking/AFXMLRequestOperation.m
	AFNetworking/NSString+AFNetworking.h
	Example/Classes/AFGowallaAPIClient.h
	Mac Example/AppDelegate.h
	Mac Example/AppDelegate.m
	Mac Example/Classes/AFGowallaAPIClient.h
	iOS Example/Classes/AFGowallaAPIClient.h
…rking

Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFHTTPRequestOperation.h
	AFNetworking/AFHTTPRequestOperation.m
	AFNetworking/AFJSONRequestOperation.h
	AFNetworking/AFJSONRequestOperation.m
	AFNetworking/AFPropertyListRequestOperation.h
	AFNetworking/AFPropertyListRequestOperation.m
	AFNetworking/AFXMLRequestOperation.h
	AFNetworking/AFXMLRequestOperation.m
Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFImageRequestOperation.h
	AFNetworking/AFImageRequestOperation.m
	AFNetworking/AFJSONRequestOperation.h
	AFNetworking/AFXMLRequestOperation.m
…parent have a say in the isReady process so it can check dependent NSOperations.
…ng their responses. Dependent operations may need the response after one has completed. This also simplifies things a little.
@mattt
Copy link
Contributor

mattt commented Nov 26, 2011

Thanks for sharing these changes. I'm not sure if this functionality wouldn't be better-suited for AFHTTPClient. The current solution for backgrounding involves 3 lines in the app delegate, as described in this StackOverflow question. I'd consider making this a property of the client, which would make it a bit easier and more obvious—especially for new users.

@zbowling
Copy link
Author

you're right. we have a better approach. going to push it later.

@zbowling zbowling closed this Nov 27, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants