简体   繁体   中英

iOS Parse.com SDK: Handling Errors

SITUATION I am trying to figure out the best practices for error handling with the parse.com iOS SDK. I have read the parse docs and they do a great job of documenting how to check for connectivity to parse and if objects can be found, but my question would be what do I do then?

EXAMPLE

[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

        if ([error code] == kPFErrorConnectionFailed) {
            //COULD NOT REACH PARSE

            //SO WHAT NOW?
        }

        else {
            //EVERYTHINGS COOL
        }

    }];

SO WHAT NOW? Am I supposed to have this on an NSTimer and fire this off again in 5 minutes to see if we can reach parse then?

If saving objects is as important as it seems to be for your case, then this could be a solution, instead of using an NSTimer:

In the SO WHAT NOW? block, just call the method that saves this object recursively. If you ever get an error other than ConnectionFailed you could handle that appropriately, but if you're just worried about saving this even if the first attempt fails, this could be a way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM