ios - 完成以下错误 "This query has an outstanding network connection. You have to wait until it'。”

标签 ios xcode parse-platform

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

因为我只运行一个查询 任何人都可以在这里帮忙,因为我是新手解析

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

您正在执行查询,这会导致您遇到的行为,因为表 Controller 也在尝试执行它。

关于ios - 完成以下错误 "This query has an outstanding network connection. You have to wait until it'。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24842866/

相关文章:

objective-c - 在代码中调整 View 大小不起作用

ios - 我正在尝试用用户列表填充 TableView ,但 TableView 不会加载任何内容

java - 查询自定义对象时出现 ParseException : no results found for query. 代码 101

ios - UIView 子类认为它是一个 UITabBarController

ios - 从核心数据中检索 UUID 并设置 UUID 变量不起作用

swift - 由 Parse.com 给出的登录/注册代码,有二元运算符错误

iOS 自定义键盘扩展自动布局

ios - 如何更正 xcode 异常对我的应用所做的更改?

ios - willDisplayCell 不会改变符合逻辑的背景颜色

javascript - 在 Windows 中测试/调试 Phonegap iOS 应用程序