Inside my unwind action method for my unwind segue, I send data to a remote database, and it verifies if the information was successfully stored in the database.
I plan on having my verification function return a 0 or 1, for success or failure, and I'm planning on using that as the condition.
I'm curious if there is a way to abort the unwind segue inside of the unwind action method? (Or should I just do this verification before the unwind segue begins and prevent the unwind segue from even beginning somehow?)
I've already read ios segue "cancel" but I don't know what they mean when they say to override the
-[UIViewController shouldPerformSegueWithIdentifier:sender:]
method. Do I just make my own custom version of this method (see below) and call it inside the unwind action method, and make it return no/yes depending on my condition? I tried overriding the method with:
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if (database verification fails) {
return NO;
}
return YES;
}
and I called it inside my unwind action method, however it didn't cancel the unwind segue.
Am I doing something incorrectly, or is there another way to abort the unwind segue inside the unwind action method?
I am new to iOS, so I'm sorry if this question sounds silly. Thanks for any help!
It would probably be best if you just check the result of your data base and then perform the segue. The first segment of code that you posted won't get modified that much, but if you already have your unwind segue made and working, then the only thing you would add to your code to check, would be something like this (lets say your database returns YES and you make it an NSString called returnResult):
if ([returnResult isEqualToString:@"YES"])
{
[self performSegueWithIdentifier:@"unwindSegueName" sender:self];
}
else
{
//do whatever here if the value equals anything other than "YES"
}
Your if statement will vary depending on the data that you get back from the database, but you would still just use an plain if
conditional.
FYI, Posting more code will get you more complete answers. If you posted what the return data from the database looked like, then I could have showed you how to use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With