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...
If you use NSURL's getResourceValue:forKey:error:
method, which I guess you are because you mentioned using NSURLUbiquitousItemIsUploadedKey
, you can see files apparently not uploading because NSURL caches the resource value under very particular circumstances.
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:
The behavior of resource value caching is slightly different between
the NSURL and CFURL API.
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.
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.
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.
Basically, if you use getResourceValue: on any thread other than the main thread it will cache the first result, and return this same result to you time and time again. 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...
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 appeared to fix the issue. Forcing getResourceValue:forKey:error:
to run only on the main thread finally got rid of this niggle in one fell stroke.