- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
-(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;
}
它正在崩溃,并产生上述错误。我编译了它,它崩溃了
NSString *cellData = [data objectAtIndex:indexPath.row];
声明。请帮助,提前致谢:)
最佳答案
检查 object
obtained
from array
是 string
还是 array
就像使用 isKindOfClass
像这样修改:
-(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;
}
关于ios - __NSCFConstantString objectAtIndex :]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26928806/
我基本上得到这个错误 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognize
全部。当我使用 NSTableView 时,只要到达这个函数就会出现以下错误。 -(id)tableView:(NSTableView *)tableView viewForTableColumn:(
当您自己创建 Chromecast iOS 应用时,而不是从 cast-ios-sample 复制的,它将崩溃,因为框架引发了未捕获的异常。 [__NSCFConstantString gck_mat
我从服务器收到一个 JSON 响应,其中包含字典元素,其中一个元素可能是数组,它将包含诸如 ["abc","def","ghi"] 之类的值,我将这个数组分配给名为数组的变量,如下面的代码所示: se
UI Pickers让我再次陷入困境,我仍在学习UI Picker,因此不确定ive是否在这里做了根本上的错误。 尝试显示来自UIPicker行的图像。 错误: *** Terminating app
首先,抱歉问题的长度。但我一直在寻找答案。我在一个包含两个 UIScrollView 的选项卡式应用程序中创建了一个 View 。我称它们为 topScrollView 和 bottomScrollV
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(N
redSegmentedControl.m redSegmentedControl.h 现在,我在另一个 Controller 中编写代码 // self.segmentedControl = [[
当我运行我的应用程序时,我发现了一个信号 SIGABRT 线程。这是错误消息: [__NSCFConstantString _isResizable]: 无法识别的选择器发送到实例 0x5c20 问题
我使用测试用户帐户来测试我的应用内购买应用。我使用的产品名称如 #define PRODUCT_IDENTIFIER @"com.companyname.appname.P1" 当我在模拟器中运行我的
我正在尝试将属性字符串放入 NSTextField 中,它本身位于 NSAlert 中这是我的代码: NSTextField *label1 = [[NSTextField alloc]initWit
我正在将 tableView 添加到具有自定义大小的 viewController,即我正在定义其框架。我没有设置它的委托(delegate),因为我不希望 tableView 执行任何操作。即使我设
-(void)downloadResult:(id)data { if([data isKindOfClass:[NSArray class]]) { if ([data c
我是一名优秀的程序员,十分优秀!