Laurie Gray
Jul 27, 2017 · 1 min read

Hello Amir, that’s a good question.

A method and function are essentially the same thing, but in different places. Sort of if you were to go to a formal thing you would address yourself as Mr. So and So rather than your first name Amir.

A class is simply a way to keep some functionality together in a logical way that helps you, and people understand what is going on. The great thing is you can reproduce many of these as copies which helps a lot as well.

When you use a function inside of a class, then its just like bolting functionally onto it — perhaps your fade transition class which makes a lovely fade happen, has a function on it which makes that animation happen every 5 seconds. When the function is inside the class like this, it is called something else; a method. It’s just a way to distinguish between the two — a function on it’s own, or a method inside of a class.

Just remember, all of these things are there to help you write better code that you can understand after you come back and look at the code in a few days/weeks/months. Trust me; they’ll help.

Laurie

    Laurie Gray

    Written by

    iOS Developer, raywenderlich.com iOS Video Instructor Team Member & Udemy Instructor — Also known as a ‘Total Learn-o-holic’.