Read contents of url from icloud

Is it possible to read contents of an url from a file on iCloud Drive? When I try to read it returns a string that has been converted to binary? or when I do it base64string it converts it to something different. I wrote a simple file that has just text "This is a test." and it keeps converting to something different. I've also tried utf8 encoding on my file but then on the test string there is no encoding just text. Is security stoping this? I'm also doing startAccessingSecurityScopedResource() before the read. Please help or suggest.

Did you try something like this?
Code Block
if ([url startAccessingSecurityScopedResource]) {
        NSData *content = [NSData dataWithContentsOfURL:url];
      if (!content) {
          NSLog(@"Error = %@", error);
      }
        else {
            NSLog(@"content = %@", [[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding]);
        }
}
[url stopAccessingSecurityScopedResource];

Consider using NSFileCoordinator to wrap the code in a reader block if the URL is on iCloud.
Read contents of url from icloud
 
 
Q