hello,
have code:
code:
if ([variablefactors count] >= 1) { short j = 0; bool shouldrun = true; while (shouldrun) { if ([(rbmvariablefactor *)[variablefactors objectatindex:j] exponent] == 0) { //if factor empty remove [variablefactors removeobjectatindex:j]; }else{ j++; } shouldrun = (j <= ([variablefactors count] - 1)); } } when have variablefactors 1 object satisfies second if statement, gets removed before shouldrun line.
@ point check breakpoints j 0, variablefactors says '0 objects', set breakpoint after shouldrun reassigned , still true!!! while loops again , code crashes because i'm accessing empty array.
please help...
richard
i'm getting compile error on line ([(rbmvariablefactor....
last line 'shouldrun = ....' problem.
@ program:
code:
nsmutablearray *variablefactors = [nsmutablearray arraywithobjects:@"foo", nil]; nslog(@"count %lu", [variablefactors count]); [variablefactors removeobjectatindex:0]; nslog(@"count %lu after removing object @ index 0", [variablefactors count]); nslog(@"count - 1 %lu", [variablefactors count] - 1);
it outputs:
code:
mbhelp[1003:903] count 1 mbhelp[1003:903] count 0 after removing object @ index 0 mbhelp[1003:903] count - 1 18446744073709551615
the 'count' method returns unsigned int - can't negative, expecting compare j to.
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment