开发者

sticky for loop?

开发者 https://www.devze.com 2023-02-15 21:13 出处:网络
I am having a problem with a for loop. Most probably it is a silly mistake somewhere that i cant catch. I have a fast enumeration loop that looks like this:

I am having a problem with a for loop. Most probably it is a silly mistake somewhere that i cant catch. I have a fast enumeration loop that looks like this:

for (NSNumber *number in sums) {
    int n = [number intValue];

    NSArray *array = [self getResultForTarget:n];

    for (NSNumber *num in array) {
        NSLog(@"%i",[num intValue]);
    }
}

the value for [num intValue] is the same for every enumeration of for (NSNumber *number in sums) when it is impossible for it to be the same. It is giving the value it calculates in the first enumeration. The method getResultF开发者_JAVA技巧orTarget: cannot return the same result for the different (int) arguments it is taking.... what might be going wrong???

p.s. i tried to manually enter the arguments of sums in the method and it returned correct results.


If you manually entered sums and got the right results there is a good chance that the issue is that at run time sums does not contain what you think it contains.


ok i got it to work... apparently i have an initialized array that should be emptied before each call ...

0

精彩评论

暂无评论...
验证码 换一张
取 消