删除大文件时,进度条会挂起

时间:2016-02-01 06:36:06

标签: ios iphone

我在下面的代码段中添加了加载栏。它运行正常,我删除了少量数据(例如30到150 mb)。但问题是当我删除大尺寸数据时,加载条不会被加载(大约190mb)。

dispatch_async(dispatch_get_main_queue(), ^{

    [self addloading];
    if(_isProgress)
        return;
    _lastDeleteItemIndexAsked = index;
    NSInteger catalogue_id =[[[_currentData  objectAtIndex:index%[_currentData count]] valueForKey:@"catalogue_id"] integerValue];
    BOOL update_avilable = [[[online_date_array objectAtIndex:index%[_currentData count]] valueForKey:@"update_version"] boolValue];
       if(update_avilable)
        [[self GridViewDelegate] deletecatlogue_for_update:catalogue_id];
    else
        [[self GridViewDelegate] deletecatlogue:catalogue_id];

    [online_date_array replaceObjectAtIndex:index%[online_date_array count] withObject:[NotificationHandler check_online_date_of_catalogue:catalogue_id]];


    [_gmGridView reloadObjectAtIndex:index%[_currentData count] withAnimation:GMGridViewItemAnimationFade];

    [self stopLoadingfor_delete];

});

1 个答案:

答案 0 :(得分:0)

尺寸还是执行时间

我将假设self是一个UI对象。如果是,则该块应为:

Controller* __weak weakSelf = self;
dispatch_async(queue, ^{
    Controller* strongSelf = weakSelf;
    if (strongSelf) {
        ...
    }
    else {
       // self has been deallocated in the meantime.
    }
});

因此,您可能更喜欢 MVVC 解决方案,其中视图模型执行艰苦工作,而不是视图控制器。