3 Replies
      Latest reply on Jul 18, 2017 5:49 PM by photogrammer
      photogrammer Level 1 Level 1 (0 points)

        I would like to be notified when the system purges any of my ODR resources so I can update UI. (Downloaded items have an overlay to indicate that they are avaialble immediately.)

         

        Updating UI on launch/didBecomeActive might not be good enough... I assume ODR can be purged even while app is running?

         

        Any suggestions? On method is to refresh UI every 15 seconds or so but that feels hacky.

         

        Thanks in advance for any suggestions.

        • Re: ODR purge notification
          photogrammer Level 1 Level 1 (0 points)

          In case this helps anyone, I implemented a hacky solution that polls the path to each resource every few seconds to see "if it is still there". This is very lightweight, uses only a few milliseconds of cpu.

          • Re: ODR purge notification
            agart1 Apple Staff Apple Staff (50 points)

            I would like to be notified when the system purges any of my ODR resources so I can update UI. (Downloaded items have an overlay to indicate that they are avaialble immediately.)

             

            There is currently no way to be notified when ODR content is cached/purged. It is left completely up to the OS, as to which content and when that content is purged. The OS takes in several factors when deciding this content, including frequency of use, age, space availablility, and many others.

             

            Just to add that ODR was designed to be adaptive to your application, so if your app downloads new data, depending on old data will be pushed out.

             

            I would suggest starting here with "conditionally accessing the resources", which will check if a resource is already on the device:

            https://developer.apple.com/documentation/foundation/nsbundleresourcerequest/1614834-conditionallybeginaccessingresou

             

            - Hope that helps

              • Re: ODR purge notification
                photogrammer Level 1 Level 1 (0 points)

                Yes, of course, that's what I did, every few seconds I conditionally check every resource that "was" there to see if it is still there. This is at a point where I don't need the data, but I do indicate that it is already downloaded. I was thinking that a general Notification would be helpful since the system knows when it did something. :-)