Are AFNetworking success/failure blocks invoked on the main thread?
In AFNetworking 2, AFHTTPRequestOperationManager
has a completionQueue
property.
The dispatch queue for the
completionBlock
of request operations.
IfNULL
(default), the main queue is used.
#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
#else
@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue;
#endif
In AFNetworking 3, the completionQueue
property has been moved to AFURLSessionManager
(which AFHTTPSessionManager
extends).
The dispatch queue for
completionBlock
. IfNULL
(default), the
main queue is used.
@property (nonatomic, strong) dispatch_queue_t completionQueue;
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
AFNetworking 2.0.0-RC2 invokes failure block not on main thread
It seems that it was a bug, as in 2.0 final release the blocks are called on a different way, as you can see in the master branch.
AFNetworking and NSURLConnection on main thread
AFNetworking is running on a child thread not in main thread, but every thread has a main method, which is on the image you post. This is not the main thread.Now tell me What do you want to fix?
AFNetworking 2.0 success block main thread
Notifications are sent synchronously and on the same thread when you post them so you need to switch back to the main thread, preferably before posting (though you could switch after receiving the callback).
You can use either dispatch_async
or performSelector:onMainThread:
to switch to the main thread.
Related Topics
Swift 2.0 Minimum System Version Requirement (Deployment Target)
App Submission Binary Does Not Show Up in Itunes Connect
Xcode 4.3: Codesign Operation Failed (Check That the Identity You Selected Is Valid)
How to Show a Info Window in iOS Google Maps Without Tapping on Marker
Button Tap and Long Press Gesture
How to List All Classes Conforming to Protocol in Swift
Get Udid of iOS Device Programmatically
How to Make My Uibezierpath Animated with Cashapelayer
Detect If a User Has Typed an Emoji Character in Uitextview
How to Find the Purple Port for the Front Most Application in iOS 5 and Above
Application Sticks on Osspinlocklockslow
Swift - Custom Mkannotationview, Set Label Title
How to Generate PDF File from a Xml/HTML Template in iOS
Alternatives to Weak Linking in iPhone Sdk
iOS Provisioning and Certifcates - Will Revoke/Renew Effect App Store Apps