Hello there ... I'm kind of new to the whole Mac and iPhone Development world so I did read a few books/tutorials around to get the gist of it all. But I have a question which I haven't found and answer to yet: Is it possible for me to call an IBAction into an if statement that is already inside another IBAction? I know it sound confusing so I'm going to try and explain what I'm looking to do.
this is the CadastroViewController.m (which is where I fell my problem is)
Code:
#import "CadastroViewController.h"
#import "CadastroAppDelegate.h"
#import "ListViewController.h"
@implementation CadastroViewController
@synthesize usernameField;
@synthesize passwordField;
@synthesize loginButton;
-(IBAction) login:(id)sender {
NSString *post = [NSString stringWithFormat:@"user=%@&senha=%@",usernameField.text,passwordField.text];
NSString *hostStr = @"http://.../verificar.php?";
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL = [NSData dataWithContentsOfURL: [NSURL URLWithString: hostStr]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
if([serverOutput isEqualToString:@"YES"]) {
CadastroAppDelegate *delegate = (CadastroAppDelegate *)[[UIApplication sharedApplication] delegate];
ListViewController *listView = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];
[delegate changeView:self.view toView:listView.view];
[listView release];
} else {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Erro" message:@"Usuario e/ou Senha incorretos" delegate:self cancelButtonTitle:@"Tentar Novamente" otherButtonTitles: nil, nil];
[alertsuccess show];
[alertsuccess release];
}
}
@end
So OK, this is what I do, I have a login view which get the info posted on the textFields and then sends them to an online Database, the server then sends a YES/NO responde if the user and password is from an administrator. If it's not then it sends a NO and the app shows a UIAlertView with a message. On the other hand if sends a YES response the app should change views to a view with an UIWebView in order to read the info inside the Database.
My question is, is there a way for me to make a swap IBAction and call it when the serverOutput=YES?
Now, the system works, it correctly checks the username and password to see if those are of an administrator, if they aren't the UIAlertView will come up correctly, but if they are to app just closes instead of changing the views.
I have already tried everything I could think of, so any input will be welcome. Thanks in advance!