0

I am trying to search any files using search display controller. But file inside files are not displaying in tableview. That means subfolder/files are not retrieved.

For getting file and folder I am using this code. I don't understand why subfiles are not displaying.

  if(metadata.isDirectory)
    {   
   marrFiles = [[NSMutableArray alloc]init];
    for (DBMetadata *dbObject in metadata.contents)
    {
        if (!dbObject.isDirectory)
        {
            NSString *fileName = [dbObject.path lastPathComponent];
            NSMutableDictionary *dict = [NSMutableDictionary dictionary];

            NSString *stringSize = [NSString stringWithFormat:@"%@",[dbObject humanReadableSize]];
            NSDate *modificationDate = [dbObject lastModifiedDate];
            NSString *dateString = [dateFormatter stringFromDate:modificationDate];
            dateString = [dateString createdTimeString];
            [dict setValue:fileName forKey:@"File"];

            NSString *stringInfo = [NSString stringWithFormat:@"%@ %@",stringSize,dateString];
            [dict setValue:stringInfo forKey:@"Size"];
            [dict setValue:@"No" forKey:@"isSelected"];
            [marrFiles addObject:dict];
        }
        else
        {
            NSString *fileName = [dbObject.path lastPathComponent];
            NSMutableDictionary *dict = [NSMutableDictionary dictionary];

            [dict setValue:@"No" forKey:@"isSelected"];
            [dict setValue:fileName forKey:[NSString stringWithFormat:@"File"]];
            [marrFiles addObject:dict];
        }
    }
    [tblDropbox reloadData];
}
else
{
    NSMutableArray *listFile=[NSMutableArray array];
    for (DBMetadata *file in metadata.contents) {
        [listFile addObject:file.filename];
    }
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
Priya
  • 61
  • 4
  • 12
  • 1
    So you think some part of that code is supposed to process "subfiles", which part is it ? – A-Live May 15 '14 at 13:14
  • Yes, I am trying to get subfiles but it display current files when you see using NSlog. When you write any keyword in search display controller that containing file display in tableview if it is inside the folder or files. – Priya May 15 '14 at 13:39
  • My question was which part of your code you think is processing "subfiles", because all I can see is parsing of the top level of hierarchy. – A-Live May 15 '14 at 14:06
  • In This part get files NSString *fileName = [dbObject.path lastPathComponent]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setValue:@"No" forKey:@"isSelected"]; [dict setValue:fileName forKey:[NSString stringWithFormat:@"File"]]; [marrFiles addObject:dic]; – Priya May 15 '14 at 14:16
  • This part of the code seems to add the dirs to datasource but do nothing to add the files from these dirs. – A-Live May 15 '14 at 16:05
  • Yes, the source of the information you're looking at is important here. Where does the "metadata" in the very first line of your posted code come from? – Greg May 15 '14 at 16:27
  • - (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata – Priya May 16 '14 at 12:19
  • loadMetadata will only give you the listing for a single folder level. If you need to see all depths in the account, use loadDelta or searchPath – Greg May 16 '14 at 14:51
  • so, I need to replace loadMetadata?? And you mean to say, Should put loadDelta rather then loadMetadata. – Priya May 19 '14 at 12:29
  • It really depends on what you're aiming to accomplish. If you want to list the contents of a specific folder, loadMetadata will work. If you want to list all files with a particular search string at once, searchPath would work. If you want to hold the entire state of the file tree in memory, loadDelta is best. – Greg May 19 '14 at 17:30

0 Answers0