Video: Understanding parameter functions

In addition to the standard functions that we've seen so far, there are more complex functions called parameter functions. So, what are parameter functions? Parameter functions are a way for functions to have more versatility. What that means is that you can provide different input for the same function. In other words, you can perform the same process with different input. In a parameter function, input is called a parameter, and it's a lot like a variable. So, what does a parameter function look like when you create it? You add a colon after the function name, the received data type is in parentheses, that's the input for the function.

iOS app development is actually simpler than you might think—even if you're not an experienced programmer. In this course, Todd Perkins bundles the most important concepts in iOS into a quick course, explaining the development process in a visual way that people of any background can understand. No programming experience required! At the end, you'll have a finished app and a basic understanding of Xcode, the toolset for developing iOS apps; building blocks like variables, functions, and conditional statements; and interface design. You can also figure out if an iOS learning path is right for you, without a lengthy time commitment.

Understanding parameter functions

In addition to the standard functions that we've seenso far, there are more complex functions called parameter functions.So, what are parameter functions?Parameter functions are a way for functions to have more versatility.What that means is that you can provide different input for the same function.In other words, you can perform the same process with different input.In a parameter function, input is called a parameter, and it's a lot like a variable.So, what does a parameter function look like when you create it?You add a colon after the function name, the receiveddata type is in parentheses, that's the input for the function.

The received data variable, or again, parameter name.And finally, when executed, the function uses a colonand then the value after the name of the function.So, let's look at an example in actualcode of what a parameter function looks like.Think of exercising.You have the concept of exercising, and that would be the function of exercising.But every time you exercise, you don't necessarilyexercise for the exact same amount of time.So if you had an app that was tracking the number of minutes that youexercised, then you could send it, whetheryou exercised for 30 minutes or 60 minutes.

And the exercise function could then add up your totalamount of exercise based on the number that's passed in.So the top two lines are executing the exercisefunction, passing in values of 30 and 60, respectively.The exercise function receives that integervalue as the number of minutes parameter.Within the function, number of minutes can be usedlike a variable that's known only to the exercise function.And again, this reduces redundancy in code, because wecan use the same function and have different input.

And so, if you wanted to keep track of the amount of exercise over a periodof time, you add to it in theamount that's passed in through number of minutes.And just like regular functions, parameter functions have the same rules.Start with a lowercase letter.Only use letters, numbers, and underscores.Use camelCase.And don't use any reserved words.

There are currently no FAQs about Programming for Non-Programmers: iOS 7.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Already a member ?

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships.
Learn more

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.