NSFileProviderExtension
を実装しようとしていますが、最初の手順では単一項目を表示しようとしています。NSFileProviderExtensionを使用してファイルが表示されない
override func enumerator(for containerItemIdentifier: NSFileProviderItemIdentifier) throws -> NSFileProviderEnumerator {
var maybeEnumerator: NSFileProviderEnumerator? = nil
if (containerItemIdentifier == NSFileProviderItemIdentifier.rootContainer) {
// TODO: instantiate an enumerator for the container root
print("Root Container")
maybeEnumerator = FileProviderEnumerator(enumeratedItemIdentifier: NSFileProviderItemIdentifier(rawValue: "rootContainer"))
} else if (containerItemIdentifier == NSFileProviderItemIdentifier.workingSet) {
// TODO: instantiate an enumerator for the working set
print("Working Set")
} else {
// TODO: determine if the item is a directory or a file
// - for a directory, instantiate an enumerator of its subitems
// - for a file, instantiate an enumerator that observes changes to the file
print("Other Stuff")
}
guard let enumerator = maybeEnumerator else {
print("Enumerator Is nil, Throwing Error")
throw NSError(domain: NSCocoaErrorDomain, code: NSFeatureUnsupportedError, userInfo:[:])
}
return enumerator
}
そして、この方法FileProviderEnumerator
で:
私は私の延長でこのメソッドをオーバーライド
func enumerateItems(for observer: NSFileProviderEnumerationObserver, startingAt page: NSFileProviderPage) {
/* TODO:
- inspect the page to determine whether this is an initial or a follow-up request
If this is an enumerator for a directory, the root container or all directories:
- perform a server request to fetch directory contents
If this is an enumerator for the active set:
- perform a server request to update your local database
- fetch the active set from your local database
- inform the observer about the items returned by the server (possibly multiple times)
- inform the observer that you are finished with this page
*/
let items = [FileProviderItem(id: "1", name: "1_file")]
observer.didEnumerate(items)
print("Finish Enumerating")
observer.finishEnumerating(upTo: nil)
}
何も今まで示していません。 1つのアイテムだけを表示するために何かすべきことはありますか?