0

我一直在寻找这个,但没有找到任何关于它的东西。我想PFQueryTableViewController使用ViewController. 问题是程序加载Query之前获取有关segue的信息,因此Query每次都会导致空搜索。

那是我的第一集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;

}

这是我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;
}

如何在程序构建查询以安装表之前加载 segue?

PS。我已经尝试过perfomseguewithidentifierDidselectrowatindexPath方法中做一个,但我认为问题不在于我如何发送信息,而在于我检索它的时间

4

1 回答 1

0

我没有看到 [query findObjects:] 在任何地方被调用。现在你的查询什么都不做。此外,您的问题可能是您在查询返回结果之前将数据加载到表中。您可以发布如何/何时将数据加载到表中的代码吗?

于 2014-06-10T17:01:06.907 回答