[英]Error: no results matched the query
method in one class: 一类方法:
- (IBAction)createGroup:(id)sender {
PFObject *message = [PFObject objectWithClassName:@"Messages"];
[message setObject:self.recipients forKey:@"recipientIds"];
[message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else [self performSegueWithIdentifier:@"showDate" sender:self];
}];
}
then in another: 然后在另一个:
else {
PFQuery *message = [PFQuery queryWithClassName:@"Message"];
[message getObjectInBackgroundWithId:@"message" block:^(PFObject *message, NSError *error) {
[message setObject:file forKey:@"file"];
[message setObject:fileType forKey:@"fileType"];
[message setObject:[[PFUser currentUser] objectId] forKey:@"senderId"];
[message setObject:[[PFUser currentUser] username] forKey:@"senderName"];
[message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
When I run the app, there are no errors or warnings but it terminates throwing the error when the query is accessed. 当我运行该应用程序时,没有错误或警告,但是在访问查询时它会终止抛出错误。 I'm sure it is something simple that I am overlooking as I just popped my programming cherry a week ago.
我确定这是一个简单的事情,我一周前刚刚弹出编程小结时就忽略了它。 Any help would be greatly appreciated.
任何帮助将不胜感激。 Cheers!
干杯!
The getObjectInBackgroundWithId:block:
expects a Parse object ID for the objectId
parameter. getObjectInBackgroundWithId:block:
需要一个objectId
参数的Parse对象ID。
If you're simply creating the object and then trying to pass it through to a child view controller, it might be better to pass through the actual PFObject
. 如果您只是创建对象,然后尝试将其传递给子视图控制器,则最好传递实际的
PFObject
。
//In your header
@property (nonatomic, strong) PFObject *message;
//Implementation
(IBAction)createGroup:(id)sender {
PFObject *message = [PFObject objectWithClassName:@"Messages"];
[message setObject:self.recipients forKey:@"recipientIds"];
[message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.message = message;
[self performSegueWithIdentifier:@"showDate" sender:self];
}
}];
}
You'll need to implement prepareForSeque:sender:
in your view controller, and then pass the PFObject through to the child view controller: 您需要在视图控制器中实现
prepareForSeque:sender:
:,然后将PFObject传递给子视图控制器:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDate"]) {
YourChildViewController *destViewController = segue.destinationViewController;
destViewController.message = self.message;
}
}
Then in your child view controller: 然后在您的子视图控制器中:
//In the header, create a property to hold the message object
@property (nonatomic, strong) PFObject *message;
//In the body, you can use self.message
[self.message setObject:file forKey:@"file"];
[self.message setObject:fileType forKey:@"fileType"];
[self.message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.