Fire Fist
Fire Fist

Reputation: 7060

Load iCloud document from subFolder in iOS

I have successfully created Folder named Note in iCloud.

I know the way to load files from iCloud Document directory.

But i don't know how to load from Notes Folders.

I only want to load all documents from Note Folder. not from Document directory.

The directory path is like that : "iCloud>Documents>Notes"

Here is some of my codes that load data from iCloud Document Folder.

[self.notes removeAllObjects];
    NSMutableArray* tmpFileList = [[NSMutableArray alloc] init];    
    for (NSMetadataItem *item in [query results])
    {
        NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
        Note *doc = [[Note alloc] initWithFileURL:url];
        doc.lastModDate = [item valueForAttribute:NSMetadataItemFSContentChangeDateKey];
        [tmpFileList addObject:doc];
    }

    NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastModDate" ascending:NO];
    self.notes = [NSMutableArray arrayWithArray:[tmpFileList sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]]];

    [self.tblMainTableView reloadData];

How can i load it?

Upvotes: 0

Views: 138

Answers (1)

Dave Teare
Dave Teare

Reputation: 589

If your query is returning files from all directories, you could just filter out files that aren't in your Notes directory. Use something like [url pathComponents] and see if the last folder is "Notes".

With that said, it sounds like you want more control over how your files are stored in iCloud so you may want to use the "shoebox" approach as discussed in WWDC 2012 Session 237 - Advanced iCloud Document Storage.

Upvotes: 1

Related Questions