简体   繁体   English

Parse.com Segue不会传递数据

[英]Parse.com segue won`t pass data

I have 2 tableviews, both filled with data. 我有2个表视图,都充满了数据。 Both have segue to detailView.One is filled with animals and second one with countries. 两者都与detailView保持联系。第一个充满动物,第二个充满国家。 I would like to pass data to display from detail with animals to detail with countries according to the country where the animals lives. 我想传递数据以根据动物的居住地从动物的详细信息显示到国家的详细信息。 Already have PFObject in countryDetail.h made because of moving data from countrymainController. 由于从countrymainController中移出了数据,因此在countryDetail.h中已经制作了PFObject。 NSlog in segue returns me all values correctly from Parse. segue中的NSlog从Parse中正确返回了我所有的值。 Thanks for any advice 感谢您的任何建议

animalDetail.m animalDetail.m

  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"sendi"])
        {


            ViewControllerimagescale *vco = [segue destinationViewController];
            vco.bomb = self.objc;
        }else{
            PFQuery *query = [PFQuery queryWithClassName:@"Countries"];
            [query whereKey:@"Wherelive" equalTo:[self.objc objectForKey:@"CouWherelive"]];
            [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
                if (!error) {
                    for (PFObject *object in objects) {
                        ViewControllerDetail *vco = [segue destinationViewController];
                        vco.objc = object;
                        NSLog(@"KOKOE%@", object);

                    }

                } else {
                    NSLog(@"Error: %@ %@", error, [error userInfo]);
                }
            }];
        }
    }

in countrydetail.h have normally set pfobject 在countrydetail.h中通常设置了pfobject

@property (nonatomic, strong) PFObject *objc;

Actually, it is "passing". 实际上,这是“通过”。 However, the findObjectsInBackgroundWithBlock: call is asynchronous. 但是, findObjectsInBackgroundWithBlock:调用是异步的。 That means that your data ( NSArray *objects ) has a very, VERY high chance of not being fetched before the destination view controller is presented. 这意味着,您的数据( NSArray *objects )的呈现目的地视图控制器之前没有被提取的一个非常, 非常高的机会。

Either use a synchronous call like findObjects or call something like [self performSegueWithIdentifier:@"sendi" sender:nil] inside the asynchronous block. 在异步块内使用诸如findObjects类的同步调用,或诸如[self performSegueWithIdentifier:@"sendi" sender:nil]类的调用。

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

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