문제

I call this method:

  - (IBAction)createGroup:(id)sender {
    PFObject *message = [PFObject objectWithClassName:@"Messages"];
    [message setObject:self.recipients forKey:@"recipientIds"];
    [message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (error) {
            NSLog(@"Error %@ %@", error, [error userInfo]);
        }
        else {
            self.message = message;
        }
    }];
 }

When I run that by itself, it runs fine and the data class is created on Parse. But when I add a segue to the same button, it performs the segue and does not create the class on Parse. What can I do to make the same IBAction button create the class on Parse BEFORE it performs the segue?

도움이 되었습니까?

해결책

Implement prepareForSegue: in your view controller. This gets called before a segue is fired.

In your view controller, it should look like

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"mySegueIdentifier"]) {
        [self createGroup:nil];
    }
}

If the button is firing a segue in storyboard, this will get called right before it performs the segue.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top