[__NSCFString objectAtIndex:]:无法识别的选择器发送到实例Error

时间:2012-12-21 02:38:59

标签: objective-c nsmutablearray nsarraycontroller nscfstring

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

   -[__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]];

        }
      }

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

2 个答案:

答案 0 :(得分:3)

这里

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

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

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

答案 1 :(得分:2)

在此更改

[_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:[fileListArray objectAtIndex:i],@"Files",[modifiedArray objectAtIndex:i], @"Date Modified", nil]];
相关问题