iphone - IOS App switch views after login -


i'm learning develop ios in xcode 5. app uses master-detail template populates simple api i've written in php.

i want users log app app can make requests api on behalf of user. i'll explain i've set (which entirely wrong):

i've created login view , made initial view. login view controlled class named loginviewcontroller contains 'loguserin' method. when 'login' button in view pressed method sends post request api check user's credentials, app reads response see if valid. i'm stuck.

after i've determined have valid set of credentials want 2 things:

  1. save credentials use on subsequent requests
  2. switch login view master-detail view

if when app loads there valid credentials saved loginviewcontroller should switch straight master-detail view.

here's loginviewcontroller.m:

#import "ntfyloginviewcontroller.h"  @interface ntfyloginviewcontroller ()  @end  @implementation ntfyloginviewcontroller  - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  - (void)viewdidload {     [super viewdidload];      // attempt read saved credentials     // check still work     // switch master-detail view if credentials exist , valid }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  - (ibaction)loguserin:(id)sender {     nsstring *username = self.usernamefield.text;     nsstring *password = self.passwordfield.text;      // code here talks api , checks credentials,      // i've swapped pseudo code below actual code      // irrelevant      if(user logged in)     {          // save credentials         // switch master-detail view     }      // display login error     }  @end 

so, here want know:

  1. is best way go doing this?
  2. how can switch masterviewcontroller loginviewcontroller?

use keychain services save login credentials, other sensitive information not want accessible attacker.

to go master view controller, there several approaches can take. easiest display login view controller modally on top of master when app launches (or when determines user needs enter credentials). once user enters credentials , determine user authenticated, dismiss login view controller master view controller.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -