Use “dispatch_after” with caution. When pages are returned, memory cannot be released properly, which may lead to flash backout. I had a very strange flashback recently. When the APP goes from page A to page B and then returns to page A, A flash exit appears. Only appear in iPhone6 iOS13 mobile phone flash back.The original code is: go to page B to send a request, and use dispatch_after to delay sending another request after the request response comes back, presumably to solve the request small Daisy display problem. The result was a flash retreat. When you add this block to the main process queue, your page returns to the previous page, which may cause a memory release exception. Therefore, it is recommended that you do not use this method to continuously send requests. Use with caution or not use dispatch_after. You don’t want to create a bigger problem for the sake of trouble. If nothing else, use an official timer like NSTimer. I don’t really understand how technology can be avoided. Like this general mobile phone use does not flash back, but in the specific mobile phone will flash back. It’s the flash that’s the biggest problem. No code is defined and no flash log is generated. The code in question is as follows:

    @weakify(self);
    [LYRequestManager putWithURLString:[NSString stringWithFormat:@"fang/leyou/coupon/trans/boundary/update? couponAmount=%@&transId=%@",self.addcount,self.activityId] parameters:@{} success:^(id response) {
        NSLog(@"% @",response);
        [SVProgressHUD showInfoWithStatus:response[@"msg"]];
        @strongify(self);
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            @strongify(self);
            self.dataArr = [[NSMutableArray alloc]init];
            self.dataArray = [[NSMutableArray alloc]init];
            self.pageNo = @"1";
            [self requestCro];
        });
    } failure:^(NSError * error) {
        NSLog(@"% @",error);
    }];
Copy the code

Dispcth_after is the delay of adding a task in a block to the queue where it will execute, not necessarily the queue that immediately executes the task.

In the figure, the task is added to the main queue after 5 seconds. If there are other tasks in the main queue, assuming that tasks A and B are to be executed, the task will not be executed until tasks A and B are finished.