Sandeep Bansal
Sandeep Bansal

Reputation: 6394

Clarify xcode obj-c code

This is a simple one, it's just that I can't figure out what it means.

Is it 4 different methods or one method with 4 parameters.

+ (double)doCalc:(float)interestRate
                    numOfCompounds:(int)interestFrequency
                    intialDeposited:(float)deposit
                    lengthOfTimeBanked:(int)period;

What confuses me is where it comes out with numOfCompounds:(int)interestFrequency.

Does it means it's a separate parameter?

Thanks in advance.

Upvotes: 0

Views: 146

Answers (2)

BoltClock
BoltClock

Reputation: 723378

That is one method with four parameters. The whitespace and line breaks are there only for readability.

The four parameters are:

  1. interestRate, a float
  2. interestFrequency, an int
  3. deposit, a float
  4. period, an int

The name of the method, without the parameter signatures, is actually

doCalc:numOfCompounds:intialDeposited:lengthOfTimeBanked:

In one of the parts of the signature, for example numOfCompounds:(int)interestFrequency, numOfCompounds is the name of the parameter as seen by the calling code, while interestFrequency is the name of the parameter in the scope of the method.

Upvotes: 1

Alexsander Akers
Alexsander Akers

Reputation: 16024

This is all one method. The method declaration doesn't end until the closing ;.

Upvotes: 2

Related Questions