在视图控制器之间传输数据。从 Parse 加载数据时。数据在解析查询填充数据之前传输

Transferring Data between view controllers. While loading data from Parse. Data is transferred before Parse Query Populates the data

我知道如何在视图控制器之间传输数据,但是在我能够完成解析查询之前数据正在传输,因此在视图控制器之间传输数据时数据丢失了。 我使用的代码如下。第一部分与解析查询相关,最后一部分详细说明数据的发送。我怎样才能得到它,以便数据在传递到新视图之前成功存储在 phoneNUMBERS 中?因为目前是作为 NULL 传递的。

NSMutableArray *phoneNUMBERS = [NSMutableArray new];
    // Initialize table data
    PFQuery *query = [PFQuery queryWithClassName:@"friendsAssociation"];
    //quesrys the class Friend asssociation to find when instances of "user" equal the
    //logged in user's username
    [query whereKey:@"user" equalTo:usernamecontrol];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            // The find succeeded.
            NSLog(@"Successfully retrieved %d users.", objects.count);
            // Do something with the found objects
            if (objects.count == 0) {
                //uialert letting the user know that no phone number matches the query
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No User"
                                                                message:@"No user matches this username"
                                                               delegate:self
                                                      cancelButtonTitle:@"OK"
                                                      otherButtonTitles:nil];
                [alert show];








        }
        //if there is only one number matching the query

        if (objects.count >=1) {


            int i=0;

            for (PFObject *object in objects) {

                NSLog(@"%@", objects[i]);


                NSString *phonenumber = object[@"phoneNumber"];





                NSLog(@"%@", phonenumber);

                [phoneNUMBERS addObject:phonenumber];
            }





            NSLog(@"%@", phoneNUMBERS[1]);




            //if there is more than one phonenumber matching the query as
            //the user to input the friends username
            //instead


        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }}];

ContactTableViewController *contacts = [[ContactTableViewController alloc]initWithNibName:Nil bundle:Nil];
contacts.user = usernamecontrol;
contacts.PHONENUMBERS = phoneNUMBERS;


[self presentViewController:contacts animated:YES completion:Nil];

你需要放这部分代码

ContactTableViewController *contacts = [[ContactTableViewController    alloc]initWithNibName:Nil bundle:Nil]; 
contacts.user = usernamecontrol;
contacts.PHONENUMBERS = phoneNUMBERS;

[self presentViewController:contacts animated:YES completion:Nil];

进入完成块的"succesful"部分。 IE。

之后
// Do something with the found objects

并在下一行之前加上 if