ios - NSArray : 'NSInvalidArgumentException' 上无法识别的选择器

标签 ios objective-c exception

我已经坐了一个小时了,因为一些奇怪的异常。 我尝试调用一些方法:

for (int i = 0; i < [[DBElements objectAtIndex:index] count]; i++) {
            NSLog(@"selected Element: %@", [[DBElements objectAtIndex:index] objectAtIndex:i]);
            [self addElementsToView:dash withString:[[DBElements objectAtIndex:index] objectAtIndex:i] index:index andSubindex:i];
        }

该方法属于以下类型:- (void) addElementsToView: (UIView *) dash withString: (NSString *) type index:(NSInteger)index andSubindex : (int) i {}

NSLog 显示:

selected Element: NUMBER so the index stuff is ok. Why I get on the next step the following exception:

[__NSArrayI intValue]: unrecognized selector sent to instance 0x14d44f70 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI intValue]: unrecognized selector sent to instance 0x14d44f70'

更新:DBElements 是:

( ( NUMBER, LABEL ), LABEL )

索引为0 i 是 0。所以它显示为 NSString 类型的 NUMBERS。

最佳答案

尝试转换

withString:[[DBElements objectAtIndex:index] objectAtIndex:i]

像这样:

withString:(NSString *)[[DBElements objectAtIndex:index] objectAtIndex:i]

希望对您有所帮助!

关于ios - NSArray : 'NSInvalidArgumentException' 上无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24527351/

相关文章:

iOS 发布更新

ios - 如何在 swift 中允许电子邮件字符串中存在空格?

objective-c - 来自 HTTP 状态代码的 NSError

ios - 检查哪个 UIViewController 我的自定义按钮类在没有 Storyboard 的情况下

java - JXL 尝试在设置背景颜色时修改引用格式

ios - 如何获取字符串中第三个和第四个分隔字符之间的子字符串?

ios - 'sizeWithFont :constrainedToSize:lineBreakMode:'is deprecated:

objective-c - iOS Facebook 图书馆登录

C++ STL streambuf异常处理

django - 捕获 django rest 框架中的所有异常