2

Using AQGridview and the apple provided DocInteraction sample, I can represent the files in my app bundle and files provided through iTunes in the documents directory of my app in a grid format (duh). If I connect my iPad and add a file through iTunes, it adds it just fine, but when I delete a file from iTunes with the app still open, it doesn't delete the file from the grid or the array. It doesn't even raise an error when I tap on the file, it just opens an empty or blank file. How can I remove items from the array they are stored in with a foreach or forin loop (because I know that's ultimately the answer) if said item also doesn't exist in iTunes (or rather the documents directory)?

EDIT: in the context of AQGridView, my code is detecting a change in the documents directory, and is updating the NSMutableArray of objects, but the change is not being reflected on the grid. the [self.gridView deleteItemsAtIndices:<#(NSIndexSet *)#> withAnimation:<#(AQGridViewItemAnimation)#>]; method seems to not work in this case.

CodaFi
  • 43,043
  • 8
  • 107
  • 153

1 Answers1

2

I'll assume your NSArray is filled with paths as NSStrings.

NSArray *existingPaths = [paths filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *path, NSDictionary *bindings){
    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}]];
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • 2011-11-23 16:46:47.135 SheetMuse[4570:707] -[__NSGlobalBlock__ evaluateWithObject:]: unrecognized selector sent to instance 0x46578 2011-11-23 16:46:47.140 SheetMuse[4570:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSGlobalBlock__ evaluateWithObject:]: unrecognized selector sent to instance 0x46578' – CodaFi Nov 23 '11 at 23:47
  • I forgot the NSPredicate constructor. I have changed my answer. – rob mayoff Nov 24 '11 at 00:00
  • OK, I'm testing it right now. So far so good. EDIT: No Dice! Sorry, but I think it has more to do with the - (void)directoryDidChange:(DirectoryWatcher *)folderWatcher method not being called. Thanks for your answer, I'm sure it will help someone else. – CodaFi Nov 24 '11 at 00:03