URLForPublishingUbiquitousItemAtURL :expirationDate:error:
Returns a URL that can be emailed to users to allow them to download a copy of a cloud-based item.
- (NSURL *)URLForPublishingUbiquitousItemAtURL:(NSURL *)url expirationDate:(NSDate **)outDate error:(NSError**)error
Parameters
- url
- Specify the URL of the item in the cloud that you want to share. The URL must be prefixed with the base URL returned from the
URLForUbiquityContainerIdentifier:
method that corresponds to the item’s location. - outDate
- On input, a pointer to a variable for a date object. On output, this parameter contains the date after which the item is no longer available at the returned URL. You may specify
nil
for this parameter if you are not interested in the date.[NSFileManager URLForPublishingUbiquitousItemAtURL] - error
- On input, a pointer to variable for an
NSError
object. If an error occurs, this pointer is set to anNSError
object containing information about the error. You may specifynil
for this parameter if you do not want the error information.
Return Value of [NSFileManager URLForPublishingUbiquitousItemAtURL]
A URL with which users can download a copy of the item at url. Returns
nil
if the URL could not be created for any reason.Discussion of [NSFileManager URLForPublishingUbiquitousItemAtURL]
This method creates a snapshot of the specified file and places that copy in a temporary iCloud location where it can be accessed by other users using the returned URL. The snapshot reflects the contents of the file at the time the URL was generated and is not updated when subsequent changes are made to the original file in the user’s iCloud storage. The snapshot file remains available at the specified URL until the date specified in the outDate parameter, after which it is automatically deleted.
Your app must have access to the network for this call to succeed.
Example of [NSFileManager URLForPublishingUbiquitousItemAtURL]
NSURL *urlToShare = ...; NSDate *date;
NSError *error;
NSURL *sharedURL =
[[NSFileManager defaultManager] URLForPublishingUbiquitousItemAtURL:urlToShare
expirationDate:&date
error:&error];