Thursday, February 25, 2021

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

Fredrik71
Member
Registered: 2019-10-23
Posts: 625

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.

Applescript:

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)


The purpose to study someone else art is not to add, its to make less more.


Filed under: getResourceValue

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)