0
votes

I am sitting since a hour on some strange exception. I try to call some method with:

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

the method is of types: - (void) addElementsToView: (UIView *) dash withString: (NSString *) type index:(NSInteger)index andSubindex : (int) i {}

NSLog shows me:

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'

UPDATE: The DBElements is:

( ( NUMBER, LABEL ), LABEL )

index is 0 i is 0. so it shows to NUMBERS of type NSString.

2
Split up all objectAtIndex operations into different lines, enable exception breakpoint and see where it happens exactly. It's hard to predict what you have in those arrays - maybe give a dump of data you are iterating throughGrzegorz Krukowski
Your DBElements must contain objects which are not NSArraytgyhlsb
Please share the code of addElementsToView too. Also pls set a breakpoint on this method - as I understand it gives the exception trying to execute this method, is it so?nzs
So you put a breakpoint into the addElementsToView and before it captured an exception happened: with this few code information I would try to cast "withString:[[DBElements objectAtIndex:index] objectAtIndex:i]" like this: "withString:(NSString *)[[DBElements objectAtIndex:index] objectAtIndex:i]"nzs
@codedad : Yeah, you are right. It works now. Please write the answer.Watsche

2 Answers

2
votes

Try to cast

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

like this:

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

Hope it helps!

0
votes

Somewhere in your code you are calling intValue on a NSArray. Maybe in the addElementsToView method.

Looking at the (short) code sample I assume it has something to do with DBElements. You probably want to call intValue on a NSString to convert it to number value.

If you have an Arrays nested in Arrays then make sure you're calling the right selectors on the right objects.