Pregunta

I have a NSArray with 493 objects and need to create a new one with just the last 30 objects from the first array.

I know how to create a new array with the first 10 or 30 etc, but the other way around I can't.

I tried using this code:

NSArray *tempArray = [qtdPrecos subarrayWithRange:NSMakeRange([qtdPrecos count]-30, [qtdPrecos count]-1)];

But I got this error:

[NSArray subarrayWithRange:]: range {463, 492} extends beyond bounds [0 .. 492]'

So any one could help??? Thanks!!!

¿Fue útil?

Solución

The second part of the NSRange struct is length

Otros consejos

In NSMakeRange the first parameter is the start, but the second is the length of the range.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top