• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Objective C array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Objective C array
      • From: Shawn Erickson <email@hidden>
    • Re: Objective C array
      • From: Sherm Pendley <email@hidden>
    • Re: Objective C array
      • From: Carl Jochen Norum <email@hidden>
  • Prev by Date: Re: Getting font info
  • Next by Date: Re: Getting font info
  • Previous by thread: Re: Is there a Cocoa or Unix way to find all applications?
  • Next by thread: Re: Objective C array
  • Index(es):
    • Date
    • Thread