Question

I have the following block of codes in my program.

  for(int k=0;k<reqroom.count;k++)
  {
   NSString *rent=[roomRent objectAtIndex:k];

   NSString *tax=[roomTax objectAtIndex:k];

   NSString *no=[textvaluearray objectAtIndex:k];

   NSDecimalNumber *rentd=[NSDecimalNumber decimalNumberWithString:rent];
  }

//here roomRent,roomTax and textvaluearray are NSMutableArrays

This is the error that I am receiving:

'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x81b2ce0'

Thanks in advance.

Was it helpful?

Solution

From the exception "-[__NSArrayI length]:" it looks like "rent" object is not a string type and its array. Can you check the type of "rent" before converting to decimal.

OTHER TIPS

What is reqroom? Is it an NSString or NSArray (or NSMutableArray)? If it's some sort of array and you want to iterate as many times as there are objects in the array, you should probably do something like

for(int k=0;k<[reqroom count];k++)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top