【问题标题】:IOS - File Added Trigger Event - Is it possibleIOS - 文件添加触发事件 - 是否可能
【发布时间】:2015-11-04 17:34:22
【问题描述】:

我正在尝试使用 Xcode 创建的应用程序查看 Mac OS X 的下载目录。 下面是我尝试记录正在移动的文件的代码。但是,当我转到我的文档并移动文件时,甚至没有调用委托方法。有没有我想念的正确方法?

- (void)viewDidLoad {
    [super viewDidLoad];
    NSFileManager *manager = [[NSFileManager alloc] init];    // Do any additional setup after loading the view.
    [manager setDelegate:self];


    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder

    [manager changeCurrentDirectoryPath:documentsDirectory];
}

- (BOOL)fileManager:(NSFileManager *)fileManager shouldMoveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath{
    NSLog(@"Attempt to move");
    return YES;
}

【问题讨论】:

标签: ios objective-c directory nsfilemanager


【解决方案1】:

shouldMoveItemAtPath 不监视文件更改。

您需要使用 FSEvents 来获取指示文件系统更改的事件。

【讨论】:

  • 这就是我所担心的,我还没有看到任何好的 FSEvents 教程/示例。我会深入研究,谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-14
  • 2018-04-19
  • 2015-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多