Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Introduction to Objective-C Syntax Overview

Shaun Kelly
Shaun Kelly
5,648 Points

calling a method in objective-c

In a sprite kit application. How is [self addChild:node] a method ?

3 Answers

Shaun, [self addChildNode:] is called on in this case the super or parent class. You will notice these methods when subclassing other classes. For example: when you subclass NSObject, you get the basic alloc and init methods that can be used when creating an instance of that class. Although they are not programmed in your implementation, they can still be accessed from your super class or parent class.

Another Example: If you were to create a brand new Ferrari class, you could subclass the Car class (it doesn't exist through apple) to get some basic methods and properties such as the number of doors and a method like startEngine.

If you have any questions, feel free to ask!

Shaun Kelly
Shaun Kelly
5,648 Points

So an instance of a class is basically something that's been created by a class such as a object, the parent of the object is the class ? So we say "The object is an instance of that class", correct ?

Shaun, your absolutely correct! Subclassing is very popular in every language because it makes things easier to build and design with frameworks.

If you have any questions, feel free to ask!

Shaun Kelly
Shaun Kelly
5,648 Points

Is a framework a group of tools to use within your app and code to do more things?

Humza Choudry
Humza Choudry
237 Points

yes, frameworks are added to the library of the language in order to simplify coding and make things much easier for the programmer to code and understand what they have written much easier or to just add new things to the language to allow for a a lot more capability when coding.