0

I tried loading the contents of the bucket into a NSTableView using Arraycontroller. I ended uo with this error:

   -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x1006da970     

Here is the code I used to check.

 - (IBAction)checkCloud:(id)sender {

    AmazonS3Client *s3 = [AmazonClientManager s3];

    S3ListObjectsRequest* listObjectsRequest = [[S3ListObjectsRequest alloc] initWithName:@"hello-testing"];

    NSMutableArray *fileListCloud = [[NSMutableArray alloc] init];
    NSMutableArray *fileModifiedList = [[NSMutableArray alloc] init];

    @try {


    S3ListObjectsResponse* response = [s3 listObjects:listObjectsRequest];

    NSMutableArray* objectSummaries = response.listObjectsResult.objectSummaries;
    for ( S3ObjectSummary* objSummary in objectSummaries ) {

        [fileListCloud addObject:[objSummary key]];
        [fileModifiedList addObject:[objSummary lastModified]];




       }
    }
    @catch (NSException *exception) {
       NSLog(@"Cannot list S3 %@",exception);
    }


     [self loadFileListTable:fileListCloud andFileModificationDate:fileModifiedList];

    }


    -(void)loadFileListTable:(NSMutableArray *)fileListArray andFileModificationDate:(NSMutableArray *)modifiedArray{

         NSRange range = NSMakeRange(0, [[_fileListAC arrangedObjects] count]);
         [_fileListAC removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:range]];

        for(int i = 0 ; i<[fileListArray count];i++){
             [_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:[[fileListArray objectAtIndex:i] objectAtIndex:0],@"Files",[[modifiedArray objectAtIndex:i] objectAtIndex:1],@"Date Modified", nil]];

        }
      }

The array is loaded with with file names but when i add it to the array controller it throws the above mentioned error. Any help would be really great.

DesperateLearner
  • 1,115
  • 3
  • 19
  • 45
  • The `[_fileListAC addObject:...` line would be much easier to read and debug if you break it up into multiple statements. It's possible one of the objects that you think is an array is actually a string. –  Dec 21 '12 at 02:52

2 Answers2

3

Here

[[fileListArray objectAtIndex:i] objectAtIndex:0]
[[modifiedArray objectAtIndex:i] objectAtIndex:1]

[fileListArray objectAtIndex:i] and [modifiedArray objectAtIndex:i] are not NSArrays (I think they are both NSStrings).

You just need to remove the erroneous objectAtIndex:0 and objectAtIndex:1 messages.

foundry
  • 31,615
  • 9
  • 90
  • 125
2

Change here

[_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:[fileListArray objectAtIndex:i],@"Files",[modifiedArray objectAtIndex:i], @"Date Modified", nil]];
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184