FileWatcher 0.2.1

FileWatcher 0.2.1

EonistAli Oguzhan Yildiz维护。



  • 作者
  • eonist

FileWatcher

一个简单的Swift文件监视器。

Cocoapods platform Lang codebeat badge SwiftLint Sindre mit Status

安装

  • CocoaPods pod "FileWatcher"
  • Carthage github "eonist/FileWatcher" "master"
  • 手动打开 FileWatcherExample.xcodeproj

示例

这将监视您的桌面上的任何文件更改

let filewatcher = FileWatcher([NSString(string: "~/Desktop").expandingTildeInPath])

filewatcher.callback = { event in
  print("Something happened here: " + event.path)
}

filewatcher.start() // start monitoring

在后台线程上运行FileWatcher

上面的示例将在当前线程上运行FileWatcher(即其回调函数)。但是,如果您的回调需要运行很长时间(例如,在监视文件夹中的照片时,您需要在它们上运行繁琐的图像处理算法),这通常不是一个好主意。

如果您希望您的回调在后台线程上运行,您可以为它提供一个自己的队列,并且FileWatcher将使用该队列(而不是默认的当前线程/运行循环)。

filewatcher.queue = DispatchQueue.global()

笔记和文档

wiki