resourceValuesForKeys :error:
Returns the resource values for the properties identified by specified array of keys.
Parameters of [NSURL resourceValuesForKeys]
- keys
- An array of names of URL resource properties.
- error
- The error that occurred in the case that one or more resource values cannot be retrieved.
Return Value
A dictionary of resource values indexed by key.
Discussion of [NSURL resourceValuesForKeys]
If an error occurs, this method returns
nil
.
A key is left out of the returned dictionary if its corresponding resource value is not defined for the URL.
Example of [NSURL resourceValuesForKeys]
[cacheContents sortUsingComparator:^ (NSURL *a, NSURL *b) {
// get the two dates
id da = [[a resourceValuesForKeys:[NSArray arrayWithObject:NSURLCreationDateKey] error:nil] objectForKey:NSURLCreationDateKey];
id db = [[b resourceValuesForKeys:[NSArray arrayWithObject:NSURLCreationDateKey] error:nil] objectForKey:NSURLCreationDateKey];
// compare them
return [da compare:db];
}];
Example of [NSURL resourceValuesForKeys]
So... assuming
destination
is an NSURL
pointing to an item in your ubiquity container:NSError *error;
NSArray *keys = [NSArray arrayWithObject:NSURLUbiquitousItemIsUploadingKey];
NSDictionary *values = [destination resourceValuesForKeys:keys error:&error];
if (values == nil)
NSLog(@"error: %@", error);
else if ([[values objectForKey:NSURLUbiquitousItemIsUploadingKey] boolValue])
NSLog(@"uploading");
else
NSLog(@"not uploading");