Learn Objective C Tutorial For Beginners – Episode 3 – Methods

Learn Objective C Tutorial For Beginners is a series that introduces the Objective C programming language and teaches you how to write code to build iPhone apps.

Learning Objective C doesn’t have to be hard! In these tutorials, you will learn Objective C programming syntax, classes and software design patterns so that you can program iOS apps.

Combined with the Learn XCode 4 Tutorial series, you’ll be making iPhone apps in no time!

In this episode, we talk about Method Declaration and Invoking Methods

Source Code for this video: http://codewithchris.com/source-code/

For the all the episodes in this Learn Objective C Tutorial For Beginners series, visit the playlist:
http://www.youtube.com/playlist?list=PLMRqhzcHGw1YfS92iytSJCjt01FxPF9rr

For more XCode and Objective C Tutorials, visit my channel: http://www.youtube.com/user/CodeWithChris

WEBSITE: http://codewithchris.com
TWITTER: https://twitter.com/chriswching

My channel, CodeWIthChris, is about all the aspects of building iOS apps. I’ll post video tutorials on Objective C, XCode, how to submit apps to the Apple App Store, and tutorials on building various types of apps or integrating things like analytics, advertisements etc. You might even find the odd app review here or there!

If you want to see more ObjectiveC and XCode Video Tutorials, please SUBSCRIBE so that you don’t miss an episode and remember to LIKE and COMMENT if you have questions.

Intro & Outro music
“deche ok” by Gablé (http://www.gableboulga.com/)

Comments

vulkein says:

Hey Chris, nice tutorials!
However as you read through these comments you can see that there are many confused people and this is why:
It may be good to note especially when talking to people who know nothing of Objective C that you are assuming the method you created called “sampleMethodWithParameter” is being called somewhere else like in the AppDelegate. It was confusing to me because I thought you were writing a method call for this method but in fact you were only using that method to call another method you wrote called “doSomething” in the myClass class.

Perhaps what you should consider doing at the end of all your videos is to go back and point out exactly how your code is executed; showing where your code starts and which methods call which methods to get a result.

tyebillion says:

But what do you actually do with label “WithBool”, do you put it in the method call?

CodeWithChris says:

Hey Scott, what you’ve got there is that you’re trying to call the “doSomething” method on the classname. Instead you should be calling it on the variable name. So for example, this is should be your declaration:
MyClass *variablename = [[MyClass alloc] init];
[variablename dosomething];

If you still get an error, then i would check if the “dosomething” method declared in MyClass.h and implemented in MyClass.m?

Kondencuotas Pienas says:

Good stuff. Thanks for your effort doing this!

henk henkeinstein says:

Amazing 😉

Gaurav Pandey says:

.h and .m is so confusing.
Please do not consider that we know this already. When some errors come you add or change something which you are aware of but we have no clue why you did it. Suddenly there is a new thing in the flow.

I still can’t find a step-by-step tutorial for the beginners. Clearing the fundamentals of Obj-C.

1Richmar says:

Coming from a background of c/c++, C#, python, etc, this syntax is just awful. i’m excited to add Objective-C to my toolbox, but man is the language nasty.

Alex Dehe Ng says:

Using + makes it a static method?

CodeWithChris says:

Thanks for asking questions Scott! It also helps others learn. And welcome 🙂 You make it sound like a cult! lol

yelnatz says:

Coming from a C++/Java background… this syntax is weird as hell.

Behnam Jahangiri says:

hi mr chris.
really thanks for your tutorials.
 can u tell some about factory method and how much its been used and can u show an example of that?….
i road it in objective – c programming in apple developer website and that was question for me because there wasn’t enough example about Factory methods.
thanks

CodeWithChris says:

Hello! Thanks! Do you have a programming background?

The “Basics” series is the way i’m focused on teaching people who have no experience with programming but i can see how someone would find the objective-c series useful if they already have basic object oriented programming concepts!

vanmathi vanu says:

hi may i know what is appdelegate.h & appdelegate.m files what is the use of those two files whats its role & their necessaries….

CodeWithChris says:

Thanks Evan, hope to see more of you around!

CodeWithChris says:

Hey Vanmathi, please check out another one of my videos: HD
How To Build iPhone Apps – S01E04: Your XCode Project Files Demystified to find out!

CodeWithChris says:

Hey Tye, yes! So your method call would be:
[object sampleMethodWithParameter:8 withBool:YES]; (The 8 and YES are just example inputs. You can substitute with any number or NO for the bool)

CodeWithChris says:

Comment below for questions and to discuss the fact of the day! Remember to LIKE and SUBSCRIBE 🙂

Sushma Dharavath says:

video z nt clear.. its sumwat blirding 🙁

CodeWithChris says:

Thanks for watching Rob!

jaysen says:

You can do it in the HTML5 player, but since ads only work in the flash player,

and you have ads enabled, it doesn’t show up 🙂

Scott Atkinson says:

Hi Chris, thanks for the videos, I’m new to iphone development Im following your video but I have a problem this is my sample method

– (int)SameMethod:(int)SomePara
{
MyClass +Myclass = [[MyClass alloc]init];

[Myclass dosomething];
}

My error is Unknown received “Myclass” did you mean “MyClass’ in the root of my project the class is called MyClass and at the top of my page I have #import “MyClass.h”

any help would be appreciated.

Evan chukz says:

Thanks Chris, your videos are clear and understandable

Sayra López says:

So are you calling a method from your MyClass method into ANOTHER method?

Rob McCaughey says:

Thanks for these videos! They are very helpful. Keep up the good work!

Scott Atkinson says:

Thanks for your help 🙂 I’ve joined your clan of followers 😀

CodeWithChris says:

Hey Nandu, hmm i never knew you could do that! Really??

Paul McKenzie says:

I am used to working with Arduino, and one thing about that is every little thing has to be a function or declared.
Are some of the things you used, such as sampleMethod and intParam functions or does Xcode/Objective C not demand so much declaring?

Scott Atkinson says:

the error is on this line [Myclass do something];

Mallory Steele says:

Thanks for the videos. Very helpful and I like that you type when you are explaining rather than showing it already typed out.

Cheers!

CodeWithChris says:

Hey Brad! I’m glad you asked because I always thought i was strange myself (coming from the C# syntax) but never bothered to dig into it. What we recognize as the method name isn’t really the name. So for example the Obj-C method declaration looks like:

-(void) A:(int)a B:(int)b C:(int)c

All 3 parameters, a, b, c each have their own label A, B, C respectively. The method signature/name is ACTUALLY “A:B:C:” but for label A, we just write it in a way that also indicates what the method does.

chaitanya bansal says:

yes

Required Taste says:

I still haven’t been able to find a video or series that explains objective-C from the basics… everyone just starts typing code and assumes I know what it means. I’ve watched a million objective-C tutorials and I still feel like I haven’t learned anything and I’m still hopelessly confused.

NANDU MENON says:

Thanks for the videos ! Why can’t I play your video at 1.5x/2x? I am able to play other videos at increased speeds?

gopinath shiva says:

i am new to objective c and i am follwing ur videos buddy it s helpful

Hari Karthick says:

sir,video1,and video3 is nt clear……..i dont understand that videos….

Brad Satz says:

I learned some objective C in past, so this syntax does not shock me as it did when I first saw it. My question is (It has been a while since I first saw this) what’s the story with the first param on a method definition not having a label. So, the first one is built in, but all other params need their own label? Are there any exceptions to this declaration I just described?

thomas says:

so why when you have two parameters, do you suddenly give the parameter a label along with it’s name? can you give the parameter a label that is the same as it’s name and what is the use of the label?

CodeWithChris says:

Hey Scott, the “+” symbol you got there should be a “*”. Let me know what you see after changing that!

Oedelin Jean says:

lol it also took a really long list of suicidal underpaid chinese workers 

CodeWithChris says:

We’re calling the doSomething method of MyClass from another method in another class!

You can definitely call methods from within methods!

Siva Prasad says:

need tutorial Core Data with objective c (Save, Fetch, Search, Delete )
rest API with objective c for get and post methods
please provide i am struggling a lot

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!