S
S
Sergey Krivosheev2017-11-24 16:38:33
Objective-C
Sergey Krivosheev, 2017-11-24 16:38:33

Objective-c deallocated when opening a new form?

Good afternoon.
A memory error occurs while the application is running.
[5133:307051] *** -[DeclarantController retain]: message sent to deallocated instance 0x7f9e53d22b50 I

open the form after requesting data on a background thread.

dispatch_async(dispatch_get_main_queue(), ^{
                        DeclarantController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DeclarantController"];
                        viewController.consultData = self.consultData;
                        viewController.parentView = self;
                        [self.navigationController pushViewController:viewController animated:YES];
                    });

I simplified the controller, but the error pops up if you put a call to the getDeclarantKind method in viewDidLoad. If commented out, no error occurs. The error occurs even with an empty method.
@implementation DeclarantController : BaseController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self tableColor];
    [self getDeclarantKind];
}

-(NSMutableArray*)getDeclarantKind
{

}
@end

If you just go through the forms of the application, then there are no errors. An error occurs with the following algorithm:
1. Form A opens, it has a button with a transition to form B
2. Form B opens on it, an API request from the site in the background process. If the answer came, form C opens
3. Form C works fine
4. Go back with a swipe to form B and then swipe to form A
5. Repeat steps 1-3. The form opens
6. Go back with a swipe to form B and then swipe to form A
7. Repeat steps 1-3. Form C opens but the buttons slide. After clicking on any area of ​​the screen, an error occurs in main.m
int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
The most incomprehensible thing is why the error only works on the 3rd pass. The first 2 work. And if you remove [self getDeclarantKind]; that too the form is rendered and works normally.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question