Question

I have to call Parse's user signUp method on the current thread, not the background thread as it's already being called on the background thread. The -(BOOL)signUp method isn't good enough as I only get a BOOL response if the registration was successful or not, but I have to handle the potential errors.

I've noticed the method -(BOOL)signUp:(NSError **)error but my current iOS programming skills as not there yet when it comes to understanding how to use it :)

Here is the signUp: documentation

I've tried adding an extra property to my user object called NSError *latestError and I was hoping to call the mentioned method and put the NSError returned into that value so I can handle errors on the main thread:

-(BOOL)registerUser{
    PFUser *newUser = [PFUser user];
    newUser.username = self.username;
    newUser.password = self.password;
    return [newUser signUp:self.lastError]; // error
}

but I get this error:

Implicit conversion of an Objective-C ponter to 'NSError *__autoreleasing *' is disallowed with ARC

Any ideas how to make it work with this method or alternative ways to achieve the same result?

Was it helpful?

Solution

You have to pass a reference to a NSError object.. Parse will do the process and if any error is there it will update the error object with appropriate error.

You new code should be like

-(BOOL)registerUser{
    NSError *error = nil;
    PFUser *newUser = [PFUser user];
    newUser.username = self.username;
    newUser.password = self.password;
    [newUser signUp:&error]; // error

    if( error != nil)
    {
      //log the error or show alert
      return NO;
    }

    return YES;


}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top