Search code examples
iosobjective-cparse-platformuiactivityindicatorviewpfquerytableviewcontrolle

Catching the Parse kPFErrorConnectionFailed error-code & Cancelling the pullToRefresh’s UIActivityIndicatorView in the IOS PFQueryTableViewController


I have two questions as follows:

  • I will like to catch the kPFErrorConnectionFailed error-code from the query in the IOS PFQueryTableViewController’s queryForTable. How do I go about it?
  • After the last attempt to connect to Network and I receive [Error]: Network connection failed, How do I cancel the pullToRefresh’s UIActivityIndicatorView which currently continues to load indefinitely?

What I’ve tried:

  • Concerning catching error-code kPFErrorConnectionFailed, I tried the following (which does not catch the error):

    - (void)objectsDidLoad:(NSError *)error { [super objectsDidLoad:error]; if(error.code == kPFErrorConnectionFailed) {…} }


Solution

    • A work around for Catching kPFErrorConnectionFailed is to use Apple's Reachability Class to check if the Parse Network Server is reachable before trying to load data.
    • A fix to the indefinite pullToRefresh UIActivityIndicatorView is to use kPFCachePolicyCacheThenNetwork as opposed to the kPFCachePolicyNetworkOnly. The kPFCachePolicyNetworkOnly keeps trying to load data from the network even with a bad connection. However, kPFCachePolicyCacheThenNetwork relies on the cached data when the network server is unreachable. Check here for more information