Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know this is an old one, but I have been suffering this issue for a long time and have only just discovered why, so on the off chance someone else comes across this thread, here it is...</p> <p>If you use NSURL's <code>getResourceValue:forKey:error:</code> method, which I guess you are because you mentioned using <code>NSURLUbiquitousItemIsUploadedKey</code>, you can see files <em>apparently</em> not uploading because NSURL <strong>caches</strong> the resource value under very particular circumstances.</p> <p>Not mentioned anywhere in the main docs, but if you dive into NSURL.h, you find the following oddly phrased gem, which is worth reading in full to let the implications sink in:</p> <blockquote> <p>The behavior of resource value caching is slightly different between the NSURL and CFURL API.</p> <p>When the NSURL methods which get, set, or use cached resource values are used from the main thread, resource values cached by the URL (except those added as temporary properties) are invalidated the next time the main thread's run loop runs.</p> <p>The CFURL functions do not automatically clear any resource values cached by the URL. The client has complete control over the cache lifetime. If you are using CFURL API, you must use CFURLClearResourcePropertyCacheForKey or CFURLClearResourcePropertyCache to clear cached resource values.</p> <p>Returns the resource value identified by a given resource key. This method first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then this method synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller. The type of the resource value varies by resource property (see resource key definitions). If this method returns YES and value is populated with nil, it means the resource property is not available for the specified resource and no errors occurred when determining the resource property was not available. If this method returns NO, the optional error is populated. This method is currently applicable only to URLs for file system resources. Symbol is present in iOS 4, but performs no operation.</p> </blockquote> <p>Basically, if you use getResourceValue: on <strong>any thread other than the main thread</strong> it will cache the first result, and return <strong>this same result to you time and time again</strong>. Intuitive, eh? The sort of thing you think would be flagged up in big bold type in the docs, rather than buried in the header...</p> <p>For me, this manifested as devices occasionally 'sticking' as they thought a particular URL wasn't downloading, when in reality it had, ages ago. Relaunching the app often <em>appeared</em> to fix the issue. Forcing <code>getResourceValue:forKey:error:</code> to run only on the main thread finally got rid of this niggle in one fell stroke.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload