Invocation on delegate is not called while applicationWillResignActive

170 Views Asked by At

I have an application with some ViewController pushed. I login at a JSON webservice, get some data and do some work while the application is active. When the app is closed or moved to background I want to logoff off.

usually this is working, my JSON loader calls the webservice on an own thread and invocates on a delegate with the NSDictionary and an enum representing the result of the call.

I miss this invocation when my application is send to background with the following function:

- (void)applicationWillResignActive:(UIApplication *)application
{
    JSONLoader *json = self.startViewController.json;
    NSString *usr_no = [self.startViewController.user.usr_no stringValue];

    //ask json for logoff
    NSString *relativePath = [NSString stringWithFormat:@"users/%@?action=logout", usr_no];
    NSURL *logoutUrl = [NSURL URLWithString:relativePath relativeToURL:kBaseURLString];
    [json loadWithURL:logoutUrl sendResult:kJSONLogoutSuccess];
}

it does the logout, but it never reaches the procedure at the delegate where i have to assure that the logout was successful:

-(void)updatedDictionaryFromJson:(NSDictionary *)items withResult:(JsonResult)result{

    // do some other stuff..

    if (result == kJSONLogoutSuccess) {
        //user logout was successful
        NSLog(@"got some logout json");
    }
}

Why is there no invocation call when the application is going to background, anybody got some similar experience? is the application in the background yet? or should I resign the threading? any suggestions?

0

There are 0 best solutions below