编辑
有问题的代码和‘这里.因为只有通过改变参数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 :)];}返回日志的“崩溃”
03/08/2013 :04:10.650 20120:907终止应用程序二至未登录异常‘NSInvalidArgumentException’原因:‘不能对查询类型做比较:(null)’第一个抛出调用堆栈:(0x311a703e7 0x397b963 0x31a30x3x6b 0xbba53 0xa939d 0x939d 0x338975590x33859 0x338daaf5 0x3391c1e1 0x338df803 0x338d33 0x38d33 0x387ff1f1f 03x7f7f7ff7x7x7ff 0x7x7ff 0x7x7ff7 590x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x3x03x3x3x0x03x3x03x03x3x3x0x3x302x0x3x302x0x302x0x30x30x30x30x30x30x30x30x30x3x30x30x3x3x323x3270000000001:10.650 20120:907终止应用程序二到未登录异常'NSInvalidArgumentException',原因:‘不能对查询类型(Null)进行比较:(Null)’第一次抛出调用堆栈:(0x311a703a703a37833 0x38d33 0x387ff1f03x3x7f7f7f7f7f7ff7 0x7f7f7f7f7f7 0x3x3x33x3x3x323x3x3x393x330x3303x3x393x30x331c1e1 0x3x338df803 0x338d33 0x387f1f1f03x3x7f7f
/////////////////////////////////////////////////////////////////////////////////////////
我在分析(壮观的),但我不知道我错在哪里,因为我不断地从这次坠机中.:(
将apt 2终止为未命名的异常'NSInvalidArgumentException',原因是:“无法对查询类型(Null)进行比较”
如果我修改这个查询“等于PFUser当前用户在PFUser用户中不返回应用程序问题,并且它工作得很好,除了当我打开应用程序时,第一页我需要您给我当前用户的值,这是不可能的,如果不是当前用户只插入用户.
当我运行注销用户的时间并尝试再次登录时,问题就会发生.此时应用程序崩溃..。甚至屏幕上也没有显示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]; * /
}
}发布于 2013-08-02 22:52:54
在尝试执行任何需要登录的操作之前,您需要检查当前是否有登录用户。如果是[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方法。
https://stackoverflow.com/questions/18026896
复制相似问题