Tip:
Highlight text to annotate it
X
beyond the syntax changes the and signs in the square brackets the real
difference between regular classic see an objective c
is that regular c_ is a procedural programming language an objective c is
an auditory the programming language
what in a procedural programming languages like seat
the program is written as a good long procedure you know i might be split up
into files and functions to make a more modular maintain at will
is really effectively a long piece of code
combining data analogical mixed in together
but in an object oriented programming language this program would instead be
split apart into self-contained objects almost like having several many programs
each objects representing a different on the application pete object contains its
own gator
and it's own logic
and they communicate
between themselves now you can't avoid object orientation in object to see you
can't even write the simplest objective c program
without using it and while object oriented programming can bring a lot of
jargon to the table
there are really only a couple of times we need to be comfortable with the move
forward the first
and the core idea
as the idea of a classic
and an object
these two things go hand-in-hand a class is ability print
an idea
a description of definition
it describes as something
but it isn't the thing itself
like a blueprint describes
house but it isn't the house
and so well defined idea
but classes will exist for many parts of your applications
some classes you made the right yourself so you're writing our restaurant review
application you might have a class to represent a rest on another one to
represent review
across to represent a user of your ap
and these classes would also
describes them very well
there also classes to represent visual parts of an application
to building a desktop or a knife a nap there are existing classes
the represent text boxes and buttons and windows menus but classes can also
represent more invisible intangible things like dates and times owns
so you'll not only a right to your own classes
but you also use them
many that apple have already written in fact
everything you see here with the prefix and pass does already exist in the apple
frameworks
but whether your writing them or the apple right them all classes described
two things
attributes
and behavior
what are some things characteristics it's active use
and what is this behavior what can and do
so for describing a class to represent a person
we wanted to the attributes of that person on the name
a person has a height and always an agenda and then age
and then uh... there's the behavior that it describes want can they do on a
person can
walk and run and jump in speaking sleep
and defining this
is the ke when you're creating your own classes
these two pieces can also be described with other names
when we start referring to the object oriented programming jogging often
herein referred to as properties and methods
properties of the class describing the classes characteristics is after butte
and methods describing what i can do
but the class describe as everything in abstract we show that something has a
name but we don't you love the name is
because the classes the description
object
has the thing
so if the class with the blueprint the object would be the house
the object is created
from the class so obviously there's a sequence here first the classes defined
and then the object or objects are created based on the class
because you can
the same class
and make multiple objects from aunt in the same way you could take one
blueprint i make multiple houses from it
and more of a programming context we could have a class that represents a a
button in advance dot org high from application
and by creating multiple objects based on my class with a different
characteristics we can have different buttons with different heights and
weights and colors all based on that same core idea
now if you've already been exposed to object oriented programming you'll know
that is quite a lot of
jargon the comes along with it
and one of the most common things you'll hear rb for keywords that can be used
with a member of the phrase a pine abstraction polymorphism inheritance
encapsulation
while right now we don't have to care about two of them but it's worthwhile
paying attention to the a_m_a_ t_v_ abstraction and the encapsulation ideas
because that will help us
build and use
classes abstraction let's simply the idea
of focusing on the core pieces of something to describe it well of
reducing details to focus on the core concepts
it's what allows us to take the idea of multiple people
an abstract at the idea of a persian class one of the things that everything
has in common
in our code
and means that we create classes that focused only on those poor pieces of
information
and the court capabilities of that class needs to have
i'm not only that
but that's what we should expect of the classes that
people have already written that we want to use now
hand-in-hand with this
is the idea of encapsulation that we are taking the code the represents a
properties
we're taking the card represents our methods and we are wrapping it up we are
boxing it up in this class and calculated
sometimes referred to with the content of black boxing
i think we're keeping the functionality self-contained and that will only share
with other objects what we decided to share by default everything is closed
off and self-contained insider objects what does that really mean for us what
an example
t we can think of the class in essence as
eight type
we are defining say a new an astronaut gent or what's happening here is the
word in a string is representing the class but already is defined and the
object itself
is being created on the right hand side v equals sign here and the variable
message represented pointed to that object don't because we can
multiple objects based on the same class we could have another line of text too
create another object based on the same class
come when objects or created you'll often hear this referred to as
instantiation in fact the word instance and object your really interchangeable
object isn't instance of a class
now when we're working with the and a string this is a a bit of a lazy way to
do it
because we're having the object being created very simply by using the and
sign in the double quotes and mort typical environment the actual process
of creating an object
these uh... a little bit more complex and you've actually seen it already
the first in line
of any main method that we have
has this line an insult to release po
and what's happening here is really we're going to the same process
the class is and i saw to release po
we have a pointer to an object and we'll talk about point in a minute
and on the right-hand side of the equal somehow the object creation process
itself
but in the very first line of the simplest project do you have the you
have this line of code we're using classes were creating objects
we're having pointers
you can get away from this object order programming idea
but only some of the basic concepts allies net to
drill down and explore what's exactly happening on this line here