iOS Multitasking support #126

Closed
wants to merge 54 commits into
from

2 participants

@zbowling

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

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

Conflicts:
	AFNetworking/AFHTTPClient.m
a0a83a6
@zbowling zbowling fix path of this. a9e645d
@zbowling zbowling Pull this change in from other branch daaba29
@zbowling zbowling Merge github.com:seatme/AFNetworking b4335c0
@mattt mattt Updating README to point to new AFNetworking URL (https://github.com/… 920b01d
@zbowling zbowling Fix memory leak ccfcd43
@zbowling zbowling Merge branch 'master' of github.com:zbowling/AFNetworking e86aa7a
@zbowling 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
@zbowling zbowling much better solution 9088768
@zbowling zbowling change upstream and merge 11057cf
@zbowling zbowling fix a few lingering issues after the merge b3fb0bb
@zbowling zbowling new README 695ea9c
@zbowling zbowling New README for specifying the changes in our fork. 8dd9494
@zbowling zbowling Update README.md e746bf4
@zbowling 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
@zbowling zbowling add support for iOS multitasking. 16b5839
@zbowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking f1cb7aa
@zbowling zbowling Update README.md 87feccd
@zbowling zbowling move multitasking support up to AFHTTPURLRequest d56f873
@zbowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 552e0cf
@zbowling zbowling add cache policy support e2e14cc
@zbowling zbowling update readme c40ff8f
@zbowling zbowling unnecessary cast. d40e197
@zbowling 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
@zbowling zbowling A much improved design, taking cues from NSBlockOperation. 76c33a9
@zbowling zbowling autorelease return. fix regression. d2cc7af
@zbowling zbowling Update README.md 15264db
@zbowling zbowling Merge branch 'master' of github.com:seatme/AFNetworking 2449e59
@zbowling zbowling should move to finished if canceled and just started f312dde
@mattt

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

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 join this conversation on GitHub. Already have an account? Sign in to comment