PFUser当前用户解析

时间:2013-08-02 22:15:12

标签: ios parse-platform

修改

有问题的代码和'这里......因为只有通过更改PfUser用户中的参数PfUser当前用户,该应用程序不会产生问题...我忘了指出崩溃的类型......

-(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 :)];}

此'崩溃返回日志

U 03/08/2013 00:04:10.650 [20120:907] 将应用程序2终止到未捕获的异常'NSInvalidArgumentException',原因:'可以不对查询类型进行比较:(null)' 首先抛出调用堆栈: (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:终止调用抛出异常

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

我正在工作PARSE(壮观),但我无法弄清楚我错在哪里,因为我不断从这个CRASH ...... :(

终止两个未被捕获的异常'NSInvalidArgumentException',原因:'无法对查询类型进行比较:(null)'

如果我修改此查询“等于[PFUser用户]中的[PFUser当前用户],则不会返回应用程序问题并且它可以正常工作,除了当我打开应用程序时,第一页我需要你给我如果不是当前用户只插入用户...

,那么当前用户的值是不可能的

当我运行LOGOUT用户并尝试再次登录时出现问题...此时应用程序崩溃...甚至屏幕都没有显示PF登录

代码'这个,你能告诉我哪里错了吗?感谢所有

- (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 个答案:

答案 0 :(得分:4)

在尝试执行任何需要的操作之前,您需要检查是否有当前登录的用户。如果[PFUser currentUser] == nil那么您就不应该创建并尝试运行PFQuery,因为目前没有用户可以使用它来生成它。


你可以尝试:

- (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];
    }
}

当用户登录时,请确保在登录完成后调用RichiamaDatiInattesa方法(如果在后台完成)。