Tuesday, May 11, 2021

#1 2021-01-18 02:16:37 am

Registered: 2019-10-23
Posts: 707

Example using getResourceValue:forKey:error

Here is example of using isUbiquitousItemAtURL & getResourceValue method to get uploadKey
from NSURLUbiquitousItemIsUploadedKey.

It will ask for a folder (you need to point that folder to iCloud) return boolean
You could test by remove internet connection and update a file (iCloud folder) and run
the script and it will return false. Connect to internet and run the script again and it will
return true.


use framework "Foundation"
use scripting additions

set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set filemanager to current application's NSFileManager's defaultManager()

if filemanager's isUbiquitousItemAtURL:theURL then
   set {theResult, theUploadKey, theError} to (theURL's getResourceValue:(reference) forKey:(current application's NSURLUbiquitousItemIsUploadedKey) |error|:(reference))
   return theUploadKey as boolean
end if

Last edited by Fredrik71 (2021-01-18 02:17:38 am)

if you are the expert, who will you call if its not your imagination.

Filed under: getResourceValue



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)