简体   繁体   English

使用segue信息Parse.com在PFQueryTableViewController中加载查询

[英]Load a Query in PFQueryTableViewController using segue information Parse.com

I was looking for this in a while and didn't find anything about it. 我有一段时间在寻找它,却一无所获。 I want to build a table using the PFQueryTableViewController , but some informations in my Query to build this table are passed by segue in the previous ViewController . 我想使用PFQueryTableViewController来构建表,但是Query中用于构建该表的一些信息是通过segue在先前的ViewController中传递的。 The problem is the program load the Query before get the information on the segue, so the Query results in a null search every time. 问题在于程序在获取有关序列的信息之前先加载Query ,因此Query每次都会导致空搜索。

That's my segue in the first ViewController : 那是我在第一个ViewController中的ViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"vai"]) {
      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    yTableViewController *destViewController = segue.destinationViewController;

PFObject *object = [self.objects objectAtIndex:indexPath.row];

locallabel = [object objectForKey:@"local"];

destViewController.lugar = locallabel;

}

and this is my Query in the next View, which is the PFQueryTableViewController : 这是我在下一个视图中的Query ,即PFQueryTableViewController

@interface yTableViewController ()
@property (nonatomic, strong) NSMutableIndexSet *optionIndices;
@end

@implementation yTableViewController

@synthesize segint;

- (id)initWithCoder:(NSCoder *)aCoder
{
    self = [super initWithCoder:aCoder];
    if (self) {
    // Custom the table

    // The className to query on
    self.parseClassName = @"Pedidos";

   // self.parseClassName = @"Locais";

    // The key of the PFObject to display in the label of the default cell style
    self.textKey = @"local";

    // 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 = 10;
}
return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];


}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {

    // Custom initialization
    }
return self;
}



// 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)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query whereKey:@"local" equalTo:lugar]; //this is the problem of everything, when i try to find some items where the key @"local" is equal to an NSString defined in the previous PFQueryTableVC and passed from segue


if (self.objects.count == 0) {
    query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}

[query orderByDescending:@"createdAt"];


   if ([self.objects count] == 0) {
 query.cachePolicy = kPFCachePolicyCacheThenNetwork;
 }

//    [query orderByAscending:@"name"];

return query;
}

How can I load the segue before the program build the Query to mount the Table? 在程序生成查询以装入表之前,如何加载segue?

PS. PS。 I already tried to do a perfomseguewithidentifier in the DidselectrowatindexPath method, but I think that the problem is not how I am sending the information, but the time I am retrieving it 我已经尝试过做一个perfomseguewithidentifierDidselectrowatindexPath的方法,但我认为这个问题是不是我我发送信息,但当时我取回

I don't see [query findObjects:] getting called anywhere. 我看不到在任何地方调用[query findObjects:]。 Right now your query does nothing. 现在,您的查询没有任何作用。 Also your issue might be that you are loading data into the table before query can come back with the result. 同样,您的问题可能是您要在查询返回结果之前将数据加载到表中。 Can you post the code of how/when you are loading data into the table? 您可以发布将数据加载到表中的方式/时间的代码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM