簡體   English   中英

iOS-文件添加觸發事件-有可能嗎

[英]IOS - File Added Trigger Event - Is it possible

我正在嘗試使用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;
}

shouldMoveItemAtPath不監視文件更改。

您需要使用FSEvents來獲取表示文件系統更改的事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM