1

(First of, let me apologize if this is a very trivial question. I'm just starting out with iOS and Objective-C)

I'm working on an iOS 6 app which requires a verified user account in order to work. The registration is two-phased: The user first has to register his / hers name and phone number, the app will then contact a backend service which will send the user a verification code by SMS. The user then has to proceed by entering that code into the app. When all that's done the user can finally start using the app.

My question then is this: As the registration is a only-once process, what is the best way to design the flow in regard to views? My current solution is based on a "splash view" which determines where the user in in the registration process (not created, not verified or done) and then loads the correct view. This does however feel a bit cumbersome as I'm really creating a view which I'm dismissing immediately after.

Edit: As a follow-up question: If my current solution is viable, what method would be the best place to place the logic? As of now it's residing in viewDidLoad.

madLokesh
  • 1,860
  • 23
  • 49
Index
  • 2,351
  • 3
  • 33
  • 50
  • For your edit, it totally depends on your app and functionality you want to achieve. For detail, please refer Apple doc or this :http://stackoverflow.com/questions/1579550/uiviewcontroller-viewdidload-vs-viewwillappear-what-is-the-proper-division-of – Piyush Dubey Jul 18 '13 at 10:22
  • Check this also:- http://stackoverflow.com/questions/5630649/what-is-the-difference-between-viewwillappear-and-viewdidappear – Piyush Dubey Jul 18 '13 at 10:24
  • @Piyush Thank you for those links, I'll have a look. – Index Jul 19 '13 at 11:14

3 Answers3

1

You can move in this way.

Make Root View Controller just like splash screen. At Root View Controller, just check whether the app is running for first time or n-th time (after successful registration). If the app is running for first time, navigate the user to registration page and if the user had registered successfully, navigate the user to home screen(or your desired screen).


To check, whether app is running first time or not, you can use NSUserDefault.

Piyush Dubey
  • 2,416
  • 1
  • 24
  • 39
  • Thank you for your reply. Do you have any sources on this or is it from personal experience? I'll hold out a bit on accepting in case others reply with different solutions. – Index Jul 18 '13 at 10:10
  • Well, this is my own logic and I have used in many apps I developed. I have seen people using the same. And I would not have any problem on holding out for acceptance. – Piyush Dubey Jul 18 '13 at 10:20
1

you can use NSUserDefault to check whether your app is running first time or not.. If it is first time get the values save it and the move to next view.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];  
if (![defaults objectForKey:@"firstRun"])
  [defaults setObject:[NSDate date] forKey:@"firstRun"];

[[NSUserDefaults standardUserDefaults] synchronize];

Courtesy:-https://stackoverflow.com/a/1664275/1865424

I think this will help you out.

Community
  • 1
  • 1
Kundan
  • 3,084
  • 2
  • 28
  • 65
0

I am using the following code to get the current status and then load the required view, check if that helps:

-(NSString *)get_provision_status{
NSString *status;
NSUserDefaults *prefrences = [NSUserDefaults standardUserDefaults];
status=[prefrences stringForKey:@"PROVISION_STATUS"];
if ([status isEqualToString:@"(null)"] || [status rangeOfString:@"(null)"].location!=NSNotFound)
{
    status=[NSString stringWithFormat:@""];
    return status;
}
else
    return status;
}




-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    /*Process for check current provision status*/
    current_status=[self get_provision_status];
if ([current_status isEqualToString:@""] || [current_status rangeOfString:@"(null)"].location!=NSNotFound) {
    NSLog(@"First Time View");
}

else if ([current_status isEqualToString:@"PROVISION-COMPLETED"]) {
    NSLog(@"Home Screen Or view When provision completed");

}
    else
    {
        NSLog(@"Handle any other conditions if you have");
    }
    self.window.rootViewController = self.navController;
    [self.window makeKeyAndVisible];
    return YES;

}