Tip:
Highlight text to annotate it
X
after they've created a few simple projects most developers become serious
about what's actually happening in the life cycle of anaya last application
one of those other files represent
how do we get from someone touching an on a column on the iphone screen to
running the code that we write interview controller
the most basic idea is this this is an objective c program which means
are iris applications began by running
and in and i was project we do have a main dot anfal it's an odd supporting
files folder as a rule
you won't touch it you're gonna leave it alone which is why extra protein that
folder
domain
makes one call
to function cold
you wanna application main this is a predefined function i a west
the creation object
you application that represents a standard typical higher west application
it's the foundation
the pro cessing
that every i_r_s_ staff is gonna need to it
sets up overrun loops of the application stays active it responds to events and
so on
but are abt is different
from aid based dj in merritt application object and we need to say hello
we don't use inheritance for this and i wish we use delegation
and we always need a class in our project
the delegate for the standard built-in iris application on track
and this is something xcode
does for us
looking at the standard files created an a single view application you can
probably have a pretty good gas
as what the class might be that is the delegate for a application object
of course it's
at delegate dot h
an ap delegate dot pam
and this is where we can put some code to respond to application level of acts
like a
application starting an application terminating
who runs it this part of the process we have no user interface yet this is all
happening in the background
so one of the things the delegate emi jimmy needs to do is say
hey we need a user interface
and it does that mean to steps
it creates an object kohl do you want window not think about a window
the window is klia
it's transparent although it does have certain size it has bound race
and really that's what happens in higher wes
you line window object
represents the boundary seven iphone or ipod touch screen
it immediately created an exist for the lifetime of our apt is just one of them
but it is
effectively transparent is nothing in it
because what we've endu is loaded in our view controllers
which contain our user interfaces and their controller code
the dot h dot and and dot excited b files
now when we create
something like eight single view application we're loading a single view
controller into that you i wonder
in more complex applications we can switch multiple
different view controllers in
and out
of that you are window
that this looks a little intimidating darren author is allot going on here
but here's the thing
looking at this overall process
you don't touch
main
you don't touch
you i am plication mang
you don't really do anything directly with your application or with the window
object
you or interaction with this entire structure is into primary places
your ab delegate coat
and your view controller code on user interfaces
you just need to know where you are in the structure
because as your application runs and the event loop runs it's going to call
methods
like the application did finish launching with options
and all parts that
to your abdullah get covered
you get to process that and respond to it
it's palms up the you are window spawns of the view controller
and the view controller gets things like view dead load and view will appear
we can choose whether or not
to respond to these in our view controlled
when the first few controller is made active the ap is now fully active in
back in the apt delegate
we get the
application did become active notification and we can use that if we
want
this kicks off events like view did appear in the view controller
and this is all
happening
in a split second
if someone press is the home button to leave the ap we'd get things like
application will resign application did enter background but we'll see more of
those later
so what is important to know is that there's nothing really hidden behind the
scenes all this stuff is actually in your project senior application
if i jump across into a typical application i can find a main dot m i
can see the call
to you i a plication main
that's going to create that objects and pointed to our ap delegate
which is not surprisingly overhear item look
at the delegate implementation
and find this
application due to finish launching with options
how all this coming week a little confusing right now what we're doing
here
creating the window that transparent boundary the frame
online twenty two
as the code that then creates the first view controller
we have this method called ended with midmane
sore loading both the class files and the dog excited b as well
online twenty three
word loading that view controller into the window
line twenty four makes it visible
all the code is provided for you
once you understand a little bit more about
these different options and as you can see they're all quite well documented
here
it's very specifically defined and the order is explicit
this structure is provided for you in all the i_r_s_ project templates
you just have to decide where to interact with it