Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting the following error "This query has an outstanding network connection. You have to wait until it's done."

i dont understand why im getting 'This query has an outstanding network connection. You have to wait until it's done.

as i am only running one query Can anyone help out here as i am new to parse

 - (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

Can anyone help with this i am new to parse and i have done as it tells me to in the docs

like image 920
Mike J Aspinall Avatar asked Jul 19 '14 17:07

Mike J Aspinall


2 Answers

In the method queryForTable, you shouldn't execute the query, only configure and return it.

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

You were executing the query, which would cause the behavior you're experiencing, since the table controller is trying to execute it too.

like image 186
Fosco Avatar answered Sep 21 '22 04:09

Fosco


PFObject doesn't allow more than one network request on a given object at the same time.

This can happen whenever there are simultaneous calls to saveInBackground, getDataInBackground, or fetchInBackground for the same object. These methods are meant to handle asynchronous workflows, but should not be called simultaneously. These checks are intended to help developers, since two simultaneous downloads of the same resource can only negatively impact your application's performance.

Additionally, the possibility that these two fetches might download different data (i.e. the PFObject on the server changed between the calls) would likely lead to subtle and painful bugs in the application if the app used two different versions of the data interchangeably.

You may use the callback methods or blocks provided by these asynchronous functions to determine when the network operation has completed. You might also want to consider using saveEventually if your asynchronous save operation does not need a callback. You may call saveEventually multiple times on the same object, and we'll take care of queueing up these operations for you.

like image 43
Mohit Avatar answered Sep 19 '22 04:09

Mohit