2013-08-02 56 views
1

编辑PFUser当前用户解析

有问题的代码和“这个......在这里,因为只有通过改变PfUser用户参数PfUser当前用户,应用程序不产生问题......我忘了表明返回日志

ü2013年3月8日00崩溃类型...

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

这种崩溃:04:10.650 [20120:907] 终止一个第两,未捕获的异常 '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',原因:'可以(空)'

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

问题发生whe n我运行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]; */
        } 

     
} 
+0

你能复制你的实际代码吗? “if”实际上是错误的(你在哪里检查错误,但是相反)?哪一行引发异常? – Wain

+0

我编辑帖子..谢谢! –

+0

问题是什么时候没有用户登录?或者与一个临时用户? – Wain

回答

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方法被调用一次登录是完成(如果它在后台进行)。

+0

我试图理解,请原谅我:)但不会发生此问题但我有点新的这些步骤..到目前为止,'进展顺利,但现在我不明白...你能帮我明白我应该怎么做? 非常感谢:) –

+0

非常感谢你!现在的作品并没有给我更多'崩溃的应用程序...我不明白只有一件事...起初我登录时执行,标签包含当前数据的用户立即升级.. 。现在它给了我一个值为0,并更新我不得不去下一个视图,回去...怎么回事? 非常感谢你仍然是我认为的六个... –

+0

你怎么能在登录后?打电话确认登录是否完成? – Wain