Ios __NSCFConstantString objectAtIndex::发送到实例的选择器无法识别

Ios __NSCFConstantString objectAtIndex::发送到实例的选择器无法识别,ios,objective-c,iphone,xcode,uicollectionview,Ios,Objective C,Iphone,Xcode,Uicollectionview,它崩溃了,并且产生了上面提到的错误。我已经编译好了,它正在崩溃 -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"cvCell"; [self.collect registerClass:[UICollecti

它崩溃了,并且产生了上面提到的错误。我已经编译好了,它正在崩溃

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cvCell";

    [self.collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cvCell"];

    CollectionViewCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];



    NSMutableArray *data = [arr_list objectAtIndex:indexPath.section];

    NSString *cellData = [data objectAtIndex:indexPath.row];

    [cell.lbl setText:cellData];

    return cell;


}

声明。请帮助,提前感谢:)

您在
数据中存储了
arr\u list
,然后从
数据中提取并存储到字符串中

 NSString *cellData = [data objectAtIndex:indexPath.row];

因此,它不是字符串类型。您必须将其存储在适当的类型中。

检查从
数组中获取的
对象
是否为
字符串
数组
类似于使用
isKindOfClass

在这里,您的对象是NSString,您假设它是NSArray 进行如下更改:

  NSString *cellData = [data objectAtIndex:indexPath.row]

您的代码在arrData=(NSMutableArray*)处显示错误现在我做了更改,它显示“It's String”,但仍然在NSString*cellData=[data objectAtIndex:indexath.row]上崩溃;语句:(Prince通过在arrData=(NSMutableArray*)后加“;”来编辑代码。DataArru列表只是字符串数组,所以我想这样存储是可以的,还是我做错了什么?好的,然后试试:NSString*cellData=[NSString stringWithFormat:@“%@,[data objectAtIndex:indexPath.row];Log[data objectAtIndex:indexath.row]值中的值?
 -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cvCell";

    [self.collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cvCell"];

    CollectionViewCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

    id data = [arr_list objectAtIndex:indexPath.section];
    NSMutableArray *arrData = nil;
    if([data isKindOfClass:[NSString class]])
       NSLog(@"its string");
    else if([data isKindOfClass:[NSMutableArray class]])
    {
       arrData = (NSMutableArray *)data;
    }
    else
    {
       NSLog(@"its something else %@",data);
    }

    NSString *cellData = @"";
    if(arrData)
       cellData = [arrData objectAtIndex:indexPath.row];

    [cell.lbl setText:cellData];

    return cell;
}