문제

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!!!

도움이 되었습니까?

해결책

The second part of the NSRange struct is length

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top