objective c - How to redirect to new view after successful login in XCode? -


i trying build app redirects homepage after successful login. have 2 view controllers: loginviewcontroller , dashboardviewcontroller. have coded login part , have created view dashboard, not sure how redirect dashboardviewcontroller after successful login. appreciate help.

here code have loginviewcontroller.m file:

#import "loginviewcontroller.h"  @implementation loginviewcontroller  @synthesize username,password,loginbutton,indicator;  - (void)didreceivememorywarning {     // releases view if doesn't have superview.     [super didreceivememorywarning];      // release cached data, images, etc aren't in use. }  - (void)viewdidunload {     // release retained subviews of main view.     // e.g. self.myoutlet = nil; }   - (void)dealloc {     [super dealloc]; }   - (ibaction) loginbutton: (id) sender {     // todo: spawn login thread      indicator.hidden = false;     [indicator startanimating];     nsstring *post =[nsstring stringwithformat:@"username=%@&password=%@",username.text, password.text];      nsstring *hoststr = @"******";     hoststr = [hoststr stringbyappendingstring:post];     nsdata *dataurl =  [nsdata datawithcontentsofurl: [ nsurl urlwithstring: hoststr ]];     nsstring *serveroutput = [[nsstring alloc] initwithdata:dataurl encoding: nsasciistringencoding];     //nslog(@"result = '%@'", serveroutput); // space between quotes     serveroutput = [serveroutput stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]];        if([serveroutput isequaltostring:@"yes"]){           uialertview *alertsuccess = [[uialertview alloc] initwithtitle:@"congrats" message:@"you authorized"             delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];          [alertsuccess show];         [alertsuccess release];           }     else {         uialertview *alertsuccess = [[uialertview alloc] initwithtitle:@"error" message:@"username or password incorrect"             delegate:self cancelbuttontitle:@"ok"otherbuttontitles:nil, nil];         [alertsuccess show];         [alertsuccess release];         loginbutton.enabled = true;      }       loginbutton.enabled = false; }  -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event {     [self.username resignfirstresponder];     [self.password resignfirstresponder];  } 

@end

first add #import "dashboardviewcontroller.h" file in loginviewcontrller.m file

and create object of dashboardviewcontroller in

if([serveroutput isequaltostring:@"yes"]) {        dashboardviewcontroller *newview = [[dashboardviewcontroller alloc] init];        [self presentmodalviewcontroller:newview animated:yes];          uialertview *alertsuccess = [[uialertview alloc] initwithtitle:@"congrats" message:@"you authorized"             delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];          [alertsuccess show];         [alertsuccess release];  } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -