Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

Change here

[_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:[fileListArray objectAtIndex:i],@"Files",[modifiedArray objectAtIndex:i], @"Date Modified", nil]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top