ios – 收到以下错误“此查询具有出色的网络连接.你必须等到它完
发布时间:2020-12-14 17:57:14 所属栏目:百科 来源:网络整理
导读:我不明白为什么我得到 ‘此查询具有出色的网络连接.你必须等到它完成. 因为我只运行一个查询任何人都可以在这里帮忙,因为我是新手解析 - (id)initWithCoder:(NSCoder *)aCoder { self = [super initWithCoder:aCoder]; if (self) { // Customize the table /
我不明白为什么我得到
‘此查询具有出色的网络连接.你必须等到它完成. 因为我只运行一个查询任何人都可以在这里帮忙,因为我是新手解析 - (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; } 您正在执行查询,这将导致您遇到的行为,因为表控制器也尝试执行它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容