I am using AfNetworking to make POST requests. After I received response in completion block, progress hud view dismissed and in NSUserDefaults some data is saved. But when I run application, UI does not update and waits till the app crashes for a memory problem.
This is my sample code:
[[HTAPIClient sharedClient] POST:requestAddress
parameters:nil
success:^(NSURLSessionDataTask *task, id responseObject) {
if ([responseObject objectForKey:@"default_source"]) {
NSUserDefaults *usd = [NSUserDefaults standardUserDefaults];
[usd setObject:[responseObject objectForKey:@"default_source"] forKey:@"payViaCreditCard"];
[usd synchronize];
}
NSDictionary *sources = [responseObject objectForKey:@"sources"];
if (sources) {
NSArray *data = [sources objectForKey:@"data"];
if (data) {
// some code
}
}
[self.navigationController popViewControllerAnimated:YES];
[SVProgressHUD dismiss];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
// some failure
}];
Any idea how to solve this problem?
Thanks for any advance!
EDIT:
This is what say XCode in the end:
The app "MyApp" on "iPhone" quit unexpectedly. Message from debugger: Terminated due to Memory Error