2

I am very used to javascript and php programing, and I just jumped into programing Objective C. After working with it for a few weeks, the methods still confused me, as to how it is passing params, and how the methods are named.

Since I am used to php, I am used to seeing:

function myFunc($param1, $param2, $param3, $param4) {
   return FALSE;
}

Could someone show me how this would be written in Objective C, so that I can get used to writing methods that have parameters?

1

1 Answer 1

4
-(int) myFuncWithParam1: (int)param1 andParam2: (int)param2 andParam3: (int)param3 andParam4: (int)param4 {
    return 0;
}

Basically, it's not a good example, because in Objective-C method signatures are supposed to look more appealing to the human and make sense. Like [thingamajig panicWithIntensity: 12 andEagerness: 126]. But you're free to do it differently, of course.

Sign up to request clarification or add additional context in comments.

2 Comments

So, basically the method name is broken up into pieces?
@Nic exactly! It's a convenient way to remember what each parameter is supposed to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.