I am using anonymous users in parse and if they are not saved, I issue a network call to save them. The code for saving the user is as follows
PFUser* current = [PFUser currentUser];
if (!current.objectId) {
// The user is newly created, don't run any queries for them until they are saved.
[current saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
// We need a saved user to do stuff.
if (!succeeded) {
NSLog(@"Error saving user: %@", error);
} else {
NSLog(@"Saved anonymous user");
// ... load data
}
}];
return;
}
If I run this in the simulator with no internet connection, the save fails (clearly), but succeeded is true and error is nil, so my code goes into loading data even though the user was not saved. In fact the error gets logged in logs but isn't returned in the callback:
Error: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x17aa1220 {NSErrorFailingURLStringKey=https://api.parse.com/2/user_signup_or_login, NSErrorFailingURLKey=https://api.parse.com/2/user_signup_or_login, NSLocalizedDescription=The Internet connection appears to be offline., NSUnderlyingError=0x1792c880 "The Internet connection appears to be offline."} (Code: 100, Version: 1.2.20)
Is this a bug in the Parse API or am I not using something correctly?