Reputation: 455
ok so my program seem to be running fine and doing all the calculation i need, the last piece the program need is an incrementing cut list. So i have tried to build an NSMutable array and use previously set variables, which i will eventually populate a table with. only when i run the code and hit the calculate button, the program freezes, and nothing shows in NSLOG etc. can i not use previous variables set outside the for loop? or whats going on?
-(IBAction)calculateGo
{
BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication] delegate];
float iridge = ([ridge.text intValue]);
float ihip = ([hip.text intValue]);
float ispacing = ([rafterSpace.text intValue]);
float floatTLPMR = [buildNavDelegate.TLPMR floatValue];
int floatRafter = [buildNavDelegate.raftThicknessPassed intValue];
int comraftbird = [buildNavDelegate.comRaftBirdPassed intValue];
float mitre = (45 * M_PI) / 180;
float y = tanf(mitre);
float mitreThickness = sqrt((y*y)+1) * ihip;
float TLRafterSpace = (floatTLPMR * ispacing);
float firstCreeper = (TLRafterSpace + (mitreThickness/2))-(floatRafter/2);
firstCreep.text = [[NSString alloc] initWithFormat:@"%.1f", firstCreeper];
float comSetBack = floatTLPMR * (iridge/2);
comRaftSetBack.text = [[NSString alloc] initWithFormat:@"%.1f", comSetBack];
float crownSetBack = (floatTLPMR * (floatRafter/2));
crownEndSetBack.text = [[NSString alloc] initWithFormat:@"%.1f", crownSetBack];
creeperArray = [[NSMutableArray alloc] initWithCapacity:20];
for (int x = firstCreeper; x <= comraftbird; x + TLRafterSpace) {
[creeperArray addObject:[NSString stringWithFormat:@"%d", x]];
}
}
Upvotes: 0
Views: 109
Reputation: 27516
You are stuck in an infinite loop because you forgot to increment the value of x
:
for (int x = firstCreeper; x <= comraftbird; x + TLRafterSpace)
^^^^^^^^^^^^^^^^^
That should probably be:
for (int x = firstCreeper; x <= comraftbird; x += TLRafterSpace)
Upvotes: 1