Objective C array
Objective C array
- Subject: Objective C array
- From: Eric Conrad <email@hidden>
- Date: Fri, 31 May 2002 15:29:18 -0500
Hello,
I am new to Objective-C I tried getting help on this through the C
gurus on IRC, but they couldn't help either. What I want to do is read
an array with a simple for loop. Basically I'm making a simple GPA
calculating program. Here is my code:
- (IBAction)calculate:(id)sender
{
float classCredits[10];
float classGrades[10];
float totalCredits, totalGrades, gpaFinal;
int i;
for(i=0; i<10; i++)
{
classCredits[i] = [classCredit? floatValue]; <--------
classGrades[i] = [classGrade? floatValue]; <--------
}
for(i=0; i<10; i++)
{
classCredits[i]+totalCredits;
classGrades[i]+totalGrades;
}
gpaFinal = totalGrades/totalCredits;
[gpaField setFloatValue:gpaFinal];
[gpaField selectText:self];
}
The fields with the arrows pointed to them are my question, in my app I
have 10 fields for class credits and class grades each numbered 1-10. so
for example classCredit1 and classGrade1. Now how can I, in the for
loop, use the current number (i) the for loop and append it onto the end
of classGrade and classCredit. I've never tried a code like this and it
would be helpful for me to know. I had a much longer code just stating
out every variable, but an array would be so much faster in the future.
Thanks,
Eric Conrad
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.