2010-05-29 9 views

Répondre

4

Une façon serait de copier des éléments dans le répertoire conditionnel en fonction des résultats de NSFileManager s -fileExistsAtPath:isDirectory::

NSFileManager *manager = [NSFileManager defaultManager]; 
NSArray *files = [manager contentsOfDirectoryAtPath:pathFrom error:nil]; 

for (NSString *file in files) { 
    NSString *fileFrom = [pathFrom stringByAppendingPathComponent:file]; 
    BOOL isDir; 

    if (![manager fileExistsAtPath:fileFrom isDirectory:&isDir] || isDir) { 
     continue; 
    } 

    NSString *fileTo = [pathTo stringByAppendingPathComponent:file]; 
    NSError *error = nil; 
    [manager copyItemAtPath:fileFrom toPath:fileTo error:&error]; 
    if (error) // ... 
} 
+0

qui fonctionne pour moi. – Vervious