1

I have two ViewController: First:

@property (nonatomic, strong) NSBundleResourceRequest *resourceRequest ;
- (void) viewDidAppear:(BOOL)animated {

    [super viewDidAppear:animated];

    NSSet *tags1 = [NSSet setWithObjects: "1","2","3","4","5", nil];
    self.resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags1];
    self.resourceRequest.loadingPriority = 0.95;
    [self.resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:
     ^(BOOL resourcesAvailable)
     {}}];
}

and second:

@property (nonatomic, strong) NSBundleResourceRequest *resourceRequestCurrent ;
    - (void) viewDidAppear:(BOOL)animated {

        [super viewDidAppear:animated];

        NSSet *tags2 = [NSSet setWithObjects: "5", nil];
        self.resourceRequestCurrent = [[NSBundleResourceRequest alloc] initWithTags:tags2];
        self.resourceRequestCurrent.loadingPriority = NSBundleResourceRequestLoadingPriorityUrgent;
        [self.resourceRequestCurrent conditionallyBeginAccessingResourcesWithCompletionHandler:
         ^(BOOL resourcesAvailable)
         {}}];
    }

I open first View, then go to second, but I see that tags2 with PriorityUrgent downloaded after tags1.

user1884872
  • 197
  • 1
  • 3
  • 14
  • But, you started the one with low priority first right. Why don't you try adding both in the same view and then check it? – KrishnaCA Nov 04 '16 at 15:35
  • @KrishnaChaitanyaAmjuri In my App it happens in different views. – user1884872 Nov 04 '16 at 16:06
  • That's what I'm saying. These priority settings may work if you have two different tasks happening in background that you started at same time and you want one to be completed urgently. But, you already started the nonurgent task in the first view itself. By the time you have navigated to the second view, don't you think the nonurgent task would be completed or in the process of completion even before starting the urgent task. Also, the value for `loadingPriority` is between 0 and 1. Your first resource request's `loadingPriority` is 0.95. That's pretty high. – KrishnaCA Nov 05 '16 at 10:38
  • Please let me know what you think – KrishnaCA Nov 05 '16 at 10:45
  • @KrishnaChaitanyaAmjuri I tried start from one view, and tracking download progress to NSLog. Both resourceRequest downloading at the same time. Besides I tried [self.resourceRequest.progress pause] - it doesn't work too – user1884872 Nov 06 '16 at 04:15
  • What is the size of each resource (tag1 resource & tag2 resource)? Also, try changing priority parameter from 0.95 to a smaller value (0.1 or 0.05) for tag1. – KrishnaCA Nov 06 '16 at 05:43
  • @KrishnaChaitanyaAmjuri Size is near 300 mb. I tried set parameter 0.1, doesn't help – user1884872 Nov 06 '16 at 14:34
  • I just went through documentation(https://developer.apple.com/reference/foundation/nsbundleresourcerequestloadingpriorityurgent). It's written that The system will attempt to give higher priority to requests with higher values. So, we can't be sure that the request with higher priority will get downloaded first :( – KrishnaCA Nov 07 '16 at 18:03

0 Answers0