Skip to content
This repository

iOS Multitasking support #126

Closed
wants to merge 54 commits into from

2 participants

Zac Bowling Mattt Thompson
Zac Bowling

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

Commit seatme/AFNetworking@d56f873 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 some commits
Zac Bowling zbowling async fixes. changes for json d3af887
Zac Bowling zbowling I fixed something e1d89f8
Zac Bowling zbowling small change' dd84bad
Zac Bowling zbowling better foundation json support ef5bf73
Zac Bowling zbowling Merge branch 'merge_foundation_json' of github.com:seatme/AFNetworking
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
521fd35
Zac Bowling zbowling brought to much over in the merge d55245e
Zac Bowling zbowling better JSON support 2c0ef65
Zac Bowling zbowling better idea e42d89d
Zac Bowling zbowling class custer method 23ac76c
Zac Bowling zbowling should be self d6ffe69
Zac Bowling zbowling much much better ec9a8b0
Zac Bowling zbowling moved this to the same file 54f90d4
Zac Bowling zbowling moved this to the same file b3cf84e
Zac Bowling zbowling merged in upstream changes 6c1cd78
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…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
e5e6f97
Zac Bowling zbowling fixed a lot of various changes after the merge. much better bb96088
Zac Bowling zbowling forgot to mark this as concurrent. a3c3322
Zac Bowling zbowling self is never delegate. don't unset the delegate if someone else want…
…ed to be the delegate.
1511a45
Zac Bowling zbowling no such thing as an error here. 1cfe657
Zac Bowling zbowling comments. 70fd2d8
Zac Bowling zbowling dead property 9834ad4
Zac Bowling zbowling comments 932d710
Zac Bowling zbowling Foundation json should be last. 2a939e5
Zac Bowling zbowling conventions and leaks 9a6d541
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…rking

Conflicts:
	AFNetworking/AFJSONUtilities.h
bcbf99c
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…rking

Conflicts:
	AFNetworking/AFHTTPClient.m
a0a83a6
Zac Bowling zbowling fix path of this. a9e645d
Zac Bowling zbowling Pull this change in from other branch daaba29
Zac Bowling zbowling Merge github.com:seatme/AFNetworking b4335c0
Mattt Thompson mattt Updating README to point to new AFNetworking URL (https://github.com/… 920b01d
Zac Bowling zbowling Fix memory leak ccfcd43
Zac Bowling zbowling Merge branch 'master' of github.com:zbowling/AFNetworking e86aa7a
Zac Bowling zbowling Merge branch 'master' of git://github.com/gowalla/AFNetworking
Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFImageRequestOperation.h
	AFNetworking/AFImageRequestOperation.m
	AFNetworking/AFJSONRequestOperation.h
	AFNetworking/AFXMLRequestOperation.m
1d12038
Zac Bowling zbowling much better solution 9088768
Zac Bowling zbowling change upstream and merge 11057cf
Zac Bowling zbowling fix a few lingering issues after the merge b3fb0bb
Zac Bowling zbowling new README 695ea9c
Zac Bowling zbowling New README for specifying the changes in our fork. 8dd9494
Zac Bowling zbowling Update README.md e746bf4
Zac Bowling zbowling Remove silly, overly paranoid code in setCompletionBlock and let the …
…parent have a say in the isReady process so it can check dependent NSOperations.
23ca8b4
Zac Bowling zbowling add support for iOS multitasking. 16b5839
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking f1cb7aa
Zac Bowling zbowling Update README.md 87feccd
Zac Bowling zbowling move multitasking support up to AFHTTPURLRequest d56f873
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 552e0cf
Zac Bowling zbowling add cache policy support e2e14cc
Zac Bowling zbowling update readme c40ff8f
Zac Bowling zbowling unnecessary cast. d40e197
Zac Bowling zbowling Operation shouldn't finish until after the operations finish processi…
…ng their responses. Dependent operations may need the response after one has completed. This also simplifies things a little.
11159ee
Zac Bowling zbowling A much improved design, taking cues from NSBlockOperation. 76c33a9
Zac Bowling zbowling autorelease return. fix regression. d2cc7af
Zac Bowling zbowling Update README.md 15264db
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 2449e59
Zac Bowling zbowling should move to finished if canceled and just started f312dde
Mattt Thompson
Owner

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.

Zac Bowling

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 54 unique commits by 2 authors.

Sep 22, 2011
Zac Bowling zbowling async fixes. changes for json d3af887
Sep 27, 2011
Zac Bowling zbowling I fixed something e1d89f8
Oct 07, 2011
Zac Bowling zbowling small change' dd84bad
Oct 17, 2011
Zac Bowling zbowling better foundation json support ef5bf73
Oct 18, 2011
Zac Bowling zbowling Merge branch 'merge_foundation_json' of github.com:seatme/AFNetworking
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
521fd35
Zac Bowling zbowling brought to much over in the merge d55245e
Oct 21, 2011
Zac Bowling zbowling better JSON support 2c0ef65
Zac Bowling zbowling better idea e42d89d
Zac Bowling zbowling class custer method 23ac76c
Zac Bowling zbowling should be self d6ffe69
Oct 22, 2011
Zac Bowling zbowling much much better ec9a8b0
Zac Bowling zbowling moved this to the same file 54f90d4
Zac Bowling zbowling moved this to the same file b3cf84e
Nov 08, 2011
Zac Bowling zbowling merged in upstream changes 6c1cd78
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…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
e5e6f97
Zac Bowling zbowling fixed a lot of various changes after the merge. much better bb96088
Zac Bowling zbowling forgot to mark this as concurrent. a3c3322
Zac Bowling zbowling self is never delegate. don't unset the delegate if someone else want…
…ed to be the delegate.
1511a45
Zac Bowling zbowling no such thing as an error here. 1cfe657
Zac Bowling zbowling comments. 70fd2d8
Zac Bowling zbowling dead property 9834ad4
Zac Bowling zbowling comments 932d710
Zac Bowling zbowling Foundation json should be last. 2a939e5
Nov 09, 2011
Zac Bowling zbowling conventions and leaks 9a6d541
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…rking

Conflicts:
	AFNetworking/AFJSONUtilities.h
bcbf99c
Zac Bowling zbowling Merge branch 'experimental-0.8' of https://github.com/gowalla/AFNetwo…
…rking

Conflicts:
	AFNetworking/AFHTTPClient.m
a0a83a6
Zac Bowling zbowling fix path of this. a9e645d
Zac Bowling zbowling Pull this change in from other branch daaba29
Zac Bowling zbowling Merge github.com:seatme/AFNetworking b4335c0
Nov 11, 2011
Mattt Thompson mattt Updating README to point to new AFNetworking URL (https://github.com/… 920b01d
Nov 16, 2011
Zac Bowling zbowling Fix memory leak ccfcd43
Zac Bowling zbowling Merge branch 'master' of github.com:zbowling/AFNetworking e86aa7a
Zac Bowling zbowling Merge branch 'master' of git://github.com/gowalla/AFNetworking
Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFImageRequestOperation.h
	AFNetworking/AFImageRequestOperation.m
	AFNetworking/AFJSONRequestOperation.h
	AFNetworking/AFXMLRequestOperation.m
1d12038
Zac Bowling zbowling much better solution 9088768
Nov 22, 2011
Zac Bowling zbowling change upstream and merge 11057cf
Zac Bowling zbowling fix a few lingering issues after the merge b3fb0bb
Zac Bowling zbowling new README 695ea9c
Zac Bowling zbowling New README for specifying the changes in our fork. 8dd9494
Zac Bowling zbowling Update README.md e746bf4
Zac Bowling zbowling Remove silly, overly paranoid code in setCompletionBlock and let the …
…parent have a say in the isReady process so it can check dependent NSOperations.
23ca8b4
Zac Bowling zbowling add support for iOS multitasking. 16b5839
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking f1cb7aa
Zac Bowling zbowling Update README.md 87feccd
Nov 23, 2011
Zac Bowling zbowling move multitasking support up to AFHTTPURLRequest d56f873
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 552e0cf
Zac Bowling zbowling add cache policy support e2e14cc
Zac Bowling zbowling update readme c40ff8f
Zac Bowling zbowling unnecessary cast. d40e197
Zac Bowling zbowling Operation shouldn't finish until after the operations finish processi…
…ng their responses. Dependent operations may need the response after one has completed. This also simplifies things a little.
11159ee
Nov 24, 2011
Zac Bowling zbowling A much improved design, taking cues from NSBlockOperation. 76c33a9
Zac Bowling zbowling autorelease return. fix regression. d2cc7af
Zac Bowling zbowling Update README.md 15264db
Zac Bowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 2449e59
Zac Bowling zbowling should move to finished if canceled and just started f312dde
Something went wrong with that request. Please try again.