I am adding a observer to filesystem and Dbfile, but I am getting error that file already open. Please tell me where to close my file. Below is my code:
[filesystem addObserver:self forPathAndChildren:pathDB block:^(DBObserver complete){////observer to folder
DBError *error= nil;
NSLog(@"File(s) %@ changed!",pathDB);
DBFile *file=[filesystem openFile:pathDB error:&error];
[file addObserver:self block:^() { ///observer to file
DBFileStatus *newerStatus = file.newerStatus;
if (newerStatus)
{
if (!newerStatus.cached)
{
NSLog(@"newerStatus.cached == NO; this means the file downloading");
}
else
{
// Update to the newly available version and print it out
[file update:nil];
NSData *fileData = [file readData:nil];
[fileData writeToFile:[[appDelegate.directoryPath stringByAppendingPathComponent:@"Projects"] stringByAppendingFormat:@"/%@",path] atomically:YES];
[file close];
}
}];
}];