Q:

iOS 5 holding a method for sometime before it gets fired

I have implemented a autologin screen in my application which comes up first if user has saved his credentials. On that screen there is a Cancel button, for which user has a choice if he wants to cancel the autologin and wants to enter different credentials on the login screen.
I am calling the web services in the viewDidLoad and it takes around 1 second to get login automatically due to which user does not gets time to cancel the process.
I want to know if there is any solution we could hold the web services call for around 3-4 seconds so that the user would get time for cancel and then web services get called.
Any help appreciated, thanx

A:

Yes, you could use an NSTimer instead of just invoking your service call instantly.
See How do I use NSTimer? for further instructions on how to use it.
Example:
// define a timer as instance variable in your .h file
NSTimer *_loginTimer;

// use timer in your .m file
- (void) viewDidLoad {
    // initialize timer (3 seconds)
    _loginTimer = [[NSTimer scheduledTimerWithTimeInterval:3.0
        target:self
        selector:@selector(doAutoLogin)
        userInfo:nil
        repeats:NO] retain];
}

- (void) doAutoLogin {
    // request to perform login
}

- (void) cancelAutoLogin {
    // invalidate timer
    [_loginTimer invalidate];
    _loginTimer = nil;
}

