1
votes

Edit

The code in question and 'this here ... because only by changing the parameters PfUser Current User in PfUser User, the app does not create problems ... I forgot to indicate the type of Crash ...

-(void) {RichiamaDatiInattesa


PFQuery *EsamiInAttesa = [PFQuery queryWithClassName: @ "EsamiInAttesa"];

[EsamiInAttesa whereKey: @ "user" equalTo: [PFUser currentUser]];** //This is the problem Crash "Equal To: [PFUser currentUser]

[EsamiInAttesa countObjectsInBackgroundWithTarget: self selector: @ selector (countcallback: error :)];}

This' crash that returns the Log

U 03/08/2013 00:04:10.650 [20120:907] Terminating app two to uncaught exception 'NSInvalidArgumentException', reason: 'Can not do a comparison for query type: (null)' First throw call stack: (0x31a703e7 0x3976b963 0x31a70307 0xcdb6b 0xbba53 0xa939d 0xa9117 0x3389e579 0x338ded59 0x338daaf5 0x3391c1e1 0x338df803 0x338d7833 0x3387fd1f 0x3387f7ad 0x3387f1ef 0x355975f7 0x35597227 0x31a453e7 0x31a4538b 0x31a4420f 0x319b723d 0x319b70c9 0x338d646d 0x338d32b9 0xa89bd 0x39b98b20) libc + + abi.dylib: terminate called throwing an exception

/////////////////////////////////////////////////////////////////////////////////////////

I'm working PARSE (spectacular) but I can not figure out where I'm wrong because I continually from this CRASH .... : (

Terminating apt two to uncaught exception 'NSInvalidArgumentException', reason: 'Can not do a comparison for query type: (null)'

If I modify this query "equal to [PFUser current user] in [PFUser user] does not return the application problems and it works perfectly, except that when I open the application, the first page I need you to give me the values ​​of the current user and this is not 'possible if instead of current user only insert user ...

The problem occurs when I run the LOGOUT the time the user and try to log in again ... at this time the application CRASH ... Not even the screen displays PF Login

The code 'this, can you tell me where I'm wrong? thanks to all

- (void) {RichiamaDatiInattesa
    
PFQuery EsamiInAttesa * = [PFQuery queryWithClassName: @ "EsamiInAttesa"];
     [EsamiInAttesa whereKey: @ "user" equalTo: [PFUser currentUser]];
     [EsamiInAttesa countObjectsInBackgroundWithTarget: self selector: @ selector (countcallback: error :)];
}


- (void) countcallback: (NSNumber *) count error: (NSError *) error {
     if (error) {
         self.DisplayNumero.text = [NSString stringWithFormat: @ "% d tests are currently pending," [count intValue]];
          

     Else {}

         self.DisplayNumero.text = [NSString stringWithFormat: @ "Connection Absent"];
        / * [[[UIAlertView alloc] initWithTitle: @ "Missing Information"
                                     message: @ "Make sure you fill out all of the information!"
                                    delegate: nil
                           cancelButtonTitle: @ "ok"
                           otherButtonTitles: nil] show]; * /
        }

    
}
1
Can you copy your actual code. Is the if actually wrong (where you check the error but do the opposite)? Which line throws the exception?Wain
i'm edit post .. Thanks!Fabio Floris
The issue is when no user is logged in at all? Or with a temporary user?Wain
The moment I connect and code and 'present [PFUser current user] the application works as it should, it returns the right values ​​logged on user. When the user runs the offline Logout and try again riconettersi the application crashes with the error that I specified.Fabio Floris
The problem does not occur if I enter [PFUser user] instead of [PFUser current user] but in doing so the application does not return me the values ​​of the loggedFabio Floris

1 Answers

4
votes

You need to check if there is a currently logged in user before trying to perform any operations that require one. If [PFUser currentUser] == nil then you should not create and try to run your PFQuery because there is no current user to generate it with.


You could try:

- (void)RichiamaDatiInattesa {
    if ([PFUser currentUser] != nil) {
        PFQuery EsamiInAttesa * = [PFQuery queryWithClassName: @ "EsamiInAttesa"];
        [EsamiInAttesa whereKey: @ "user" equalTo: [PFUser currentUser]];
        [EsamiInAttesa countObjectsInBackgroundWithTarget: self selector: @ selector (countcallback: error :)];
    } else {
        [self countcallback:0 error:nil];
    }
}

When the user is logging in, be sure that RichiamaDatiInattesa method is called once the login is complete (if its done in the background).