收到以下错误"This query has an outstanding network connection. You have to wait until it's done."



我不明白为什么我得到'此查询具有正常的网络连接。你必须等到它完成。

因为我只运行一个查询,有人可以帮助这里,因为我是新的解析

 - (id)initWithCoder:(NSCoder *)aCoder {
    self = [super initWithCoder:aCoder];
    if (self) {
        // Customize the table
        // The className to query on
        self.parseClassName = @"Exibitor";
        // The key of the PFObject to display in the label of the default cell style
        self.textKey = @"name";
        // Uncomment the following line to specify the key of a PFFile on the PFObject to   display in the imageView of the default cell style
        // self.imageKey = @"image";
        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;
        // Whether the built-in pagination is enabled
        self.paginationEnabled = YES;
        // The number of objects to show per page
        self.objectsPerPage = 25;
     }
     return self;
    }
    #pragma mark - View lifecycle
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Uncomment the following line to preserve selection between presentations.
    //self.clearsSelectionOnViewWillAppear = NO;
    // Uncomment the following line to display an Edit button in the navigation bar for this   view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    }
    - (void)viewDidUnload
    {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    }
    - (void)viewWillAppear:(BOOL)animated
    {
    [super viewWillAppear:animated];
    }
    - (void)viewDidAppear:(BOOL)animated
    {
    [super viewDidAppear:animated];
    [super viewDidAppear:animated];
    self.canDisplayBannerAds = YES;
    }
    - (void)viewWillDisappear:(BOOL)animated
    {
    [super viewWillDisappear:animated];
    }
    - (void)viewDidDisappear:(BOOL)animated
    {
    [super viewDidDisappear:animated];
    }
    - (BOOL)shouldAutorotateToInterfaceOrientation:  (UIInterfaceOrientation)interfaceOrientation
    {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    - (void)didReceiveMemoryWarning
    {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
    }
    #pragma mark - Parse
    - (void)objectsDidLoad:(NSError *)error {
    [super objectsDidLoad:error];
    // This method is called every time objects are loaded from Parse via the PFQuery
    }
    - (void)objectsWillLoad {
    [super objectsWillLoad];
    // This method is called before a PFQuery is fired to get more objects
    }

    // Override to customize what kind of query to perform on the class. The default is to query for
     // all objects ordered by createdAt descending.
     - (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:@"Exibitor"];
    [query whereKey:@"Trade" equalTo:@"true"];
    [query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
        if (!object) {
            NSLog(@"The getFirstObject request failed.");
        } else {
            // The find succeeded.
            NSLog(@"Successfully retrieved the object.");
        }
    }];
    return query;
    }


    // Override to customize the look of a cell representing an object. The default is to display
     // a UITableViewCellStyleDefault style cell with the label being the first key in the object.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath    *)indexPath object:(PFObject *)object {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:CellIdentifier];
    }
    // Configure the cell
    cell.textLabel.text = [object objectForKey:@"text"];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"name: %@", [object  objectForKey:@"name"]];
    return cell;
     }


     /*
    // Override if you need to change the ordering of objects in the table.
    - (PFObject *)objectAtIndex:(NSIndexPath *)indexPath {
    return [objects objectAtIndex:indexPath.row];
     }
     */
    /*
     // Override to customize the look of the cell that allows the user to load the next page     of objects.
     // The default implementation is a UITableViewCellStyleDefault cell with simple labels.
     - (UITableViewCell *)tableView:(UITableView *)tableView cellForNextPageAtIndexPath:       (NSIndexPath *)indexPath {
     static NSString *CellIdentifier = @"NextPage";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault       reuseIdentifier:CellIdentifier];
     }
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
     cell.textLabel.text = @"Load more...";
     return cell;
     }
   */
    #pragma mark - Table view data source
    /*
     // Override to support conditional editing of the table view.
     - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
     {
     // Return NO if you do not want the specified item to be editable.
     return YES;
     }
     */
     /*
     // Override to support editing the table view.
      - (void)tableView:(UITableView *)tableView commitEditingStyle:   (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
 {
      if (editingStyle == UITableViewCellEditingStyleDelete) {
     // Delete the row from the data source
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]    withRowAnimation:UITableViewRowAnimationFade];
     }
     else if (editingStyle == UITableViewCellEditingStyleInsert) {
     // Create a new instance of the appropriate class, insert it into the array, and add a new    row to the table view
     }
     }
     */
   /*
     // Override to support rearranging the table view.
     - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath   toIndexPath:(NSIndexPath *)toIndexPath
     {
     }
     */
    /*
     // Override to support conditional rearranging of the table view.
     - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
     {
      // Return NO if you do not want the item to be re-orderable.
     return YES;
     }
     */
    #pragma mark - Table view delegate
     - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath   *)indexPath
     {
    [super tableView:tableView didSelectRowAtIndexPath:indexPath];
     }

    @end

有没有人可以帮助这个我是新的解析,我已经做了,因为它告诉我在文档

在方法queryForTable中,您不应该执行查询,只应该配置并返回。

- (PFQuery *)queryForTable {
  PFQuery *query = [PFQuery queryWithClassName:@"Exibitor"];
  [query whereKey:@"Trade" equalTo:@"true"];
  return query;
}

您正在执行查询,这将导致您正在经历的行为,因为表控制器也试图执行它

PFObject不允许在同一时间对给定对象进行多个网络请求。

当同一对象同时调用saveInBackground、getDataInBackground或fetchInBackground时,就会发生这种情况。这些方法旨在处理异步工作流,但不应同时调用。这些检查旨在帮助开发人员,因为同时下载两个相同的资源只会对应用程序的性能产生负面影响。

此外,如果应用程序互换使用两个不同版本的数据,这两个提取可能会下载不同的数据(即服务器上的PFObject在调用之间改变),这可能会导致应用程序中微妙而痛苦的错误。

您可以使用这些异步函数提供的回调方法或块来确定网络操作何时完成。如果异步保存操作不需要回调,您可能还需要考虑使用savefinally。您可以在同一个对象上多次调用savefinally,我们将为您处理这些操作的队列。

相关内容

最新更新