Show next ViewController in block

I have next simple code, for downloading info from service.

UIViewController *nextController;

[request authWithBlock:^(NSDictionary *result, NSError *error) 
{
    // Result of auth request
    if (!nextController) nextController = [UIViewController alloc] init];
    [navigationController pushViewController: nextController];
}];

And I need show next view when request return success. I want to know - this code are correct, or I must create and show viewcontroller in another place, not in block?

Thanks

Answers


Your code format is correct. But you can improve your code by below

__weak typeof(self) weakSelf = self;
[request authWithBlock:^(NSDictionary *result, NSError *error) 
{
    // Result of auth request
    if (!error)
    {
        UIViewController *nextController = [UIViewController alloc] init];
        // pass result to nexview controller if you want..
        [weakSelf.navigationController pushViewController: nextController];
    }

}

Need Your Help

Minor difficulties with Ajax and PHP interaction

javascript php jquery

I working in CodeIgniter and I am trying to spit out all of the items I have in a table and order them as they should be using the dropdown. I want it to happen without page reload and without submit

Space between two divs

css html css3 space

My issue is that I have two (or more) divs of the same class, that need to be spaced from each other. I cannot directly use margins however, as the last or first element would also have the margin