I'm writing a program that calculates the Jacobi algorithm. It's written in Objective-C since it runs on a Mac, but the majority is written in standard C. I'm using a two-dimensional C array and an NSArray containing 5 NSTextField labels.
The following code yields an EXC_BAD_ACCESS error:
for ( int i = 0; i < 5; i++ ) {
NSString *resultString = [NSString stringWithFormat:@"%g", matrix[i][i] ];
[[resultLabels objectAtIndex:i] setStringValue:resultString]; // error line
}
Any help?
EDIT
Here's where I init resultLabels:
resultLabels = [[NSArray alloc] initWithObjects:result11, result22, result33, result44, result55, nil];
nilvalue at all possible values ofmartix[i][i]?int0 to 9.[[resultLabels objectAtIndex:i] setStringValue:resultString];up into more lines and check for nil values for each object:NSArray* labels = resultLabels; id object = [labels objectAtIndex:i]; NSTextField* textField = (NSTextField*)object; [textField setStringValue:resultString];id object = [labels objectAtIndex:i];even after Iretainevery object inresultsLabels.po labels? What is the value ofiat that point?