NSMetadataQueryDidUpdateNotification can be used to notify your Cocoa application if you do any updation at specified directory path but first you have to prepare NSMetadataQuery and then add observer to NSNotificationCenter for NSMetadataQuery object.
- (void) setupQueryNotification { NSString* dirPath = @"/Library/Application Support/tempFolder"; //Path to folder NSMetadataQuery* query = [[NSMetadataQuery alloc] init]; [query setSearchScopes:[NSArray arrayWithObject:dirPath]]; [query setPredicate:[NSPredicatepredicateWithFormat:@"kMDItemFSName LIKE '*'"]]; NSNotificationCenter* notCenter = [NSNotificationCenter defaultCenter]; [notCenter addObserver:self selector:@selector(queryFoundStuff:) name:NSMetadataQueryDidUpdateNotification object:query]; [query startQuery]; }
Note: queryFoundStuff is the method which call if any updation occur at specified directory path. Here , I am checking updation at tempFolder.
- (void) queryFoundStuff:(NSNotification*)notification { NSLog(@"tempFolder has updated now!!!!"); }