0

我尝试使用 Arraycontroller 将存储桶的内容加载到 NSTableView 中。我以这个错误结束了uo:

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

这是我用来检查的代码。

 - (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]];

        }
      }

数组加载了文件名,但是当我将它添加到数组控制器时,它会引发上述错误。任何帮助都会非常棒。

4

2 回答 2

3

这里

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

[fileListArray objectAtIndex:i]并且[modifiedArray objectAtIndex:i]不是 NSArrays(我认为它们都是 NSStrings)。

您只需要删除错误objectAtIndex:0objectAtIndex:1消息。

于 2012-12-21T03:17:59.623 回答
2

在这里更改

[_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:[fileListArray objectAtIndex:i],@"Files",[modifiedArray objectAtIndex:i], @"Date Modified", nil]];
于 2012-12-21T04:34:08.747 回答