Tip:
Highlight text to annotate it
X
the applications we've created so far will always begin the same way we've
never saved any information for the next time the application loads after the
iphone's restarted now some of the time this is ok
job location is simple it can load and unload repeatedly without there ever
being a problem with this
but it's more likely that you will want to save some days had to persisted to
storage
on the iphone
silicon last when the device itself is restarted may first key question here is
what kind of data are you saving
option one you might be just saving a few simple values some strings bully
incinerate the very easy way to save these
as you can save them to a property list file
like the one we used in earlier to load data into a table jim
and these are useful because many of the most common objects things like
dictionaries strings and arrays just have simple methods
to save their contents directly after a file and read them back in
no option number two related to this one
is if the data you want to save
is really just
applications settings meaning preferences
free ralph
well this is an on one
you see the first suggestion is
try to write an application that does not
have much in the way of settings
now if you must apple has a very well defined set of rules for working with
settings
but something called a settings bundle
which essentially means that you can tell i a west what settings you want to
store
and they can take care of saving that data for your account
and even generating the interface for you
did using this does mean that these settings will be accessed
through the settings application on i'll ask
not your application
so it does require
the user exit out of your application to do it and then go over to the settings
that will be an entry for your program
but in the last couple of years
ample have moved from recommending this option to recommending you don't
simply because of the need to exit the apt
they don't quite see
don't ever use this but the human interface guidelines say to de-emphasize
settings in general
and using the settings af in particular
so if you have to
they suggest using your own screen
to handle application settings like having the flip side view of the stocks
have or the flip side view of the weather application
but what if it's more involved
if the data in your application can be easily stored in something like a
property list file what we have several other solutions available in iowa's for
storing and retrieving more complex content first off is the
sequel light
and court data options which are often talked about together but are very
different from each other
sequel light as it might sound
is a data base its a lightweight sequel database
but to build into ohio western we can
create and use simple tables inside
where's court date and now this is the most substantial data storage mechanism
on islands
rather than thinking about databases or flat files they let you take a complex
object graph meaning all your objects in all their data
or their references to other objects
save the whole thing just freeze dry and place when you need to
recreated from storage
coordinator is fantastic i'm a huge fan but it is notoriously unfriendly for a
new ohio s developers
and i suggest you regard it as phase to have your higher west learning first get
comfortable with the general iris development before you dive into it even
apple's own getting started with the court date a guy
begins with the phrase
kore data is not an entry-level technology
and with i a west five your pension also have the option to use the high cloud
service
if the users devices signed into high cloud
we can protect that
and we can use that so instead of just saving locally on the device itself
your have can save inside cloud
store data there
and have that day to automatically synchronized with other ohio us five
devices
and even with max in pcs
you as a developer
don't have to pay anything to apple to use this
the document saved by europe
a part of that users allocation and i clapped
now are full
exploration of sequel light coordinator or i a cloud is way beyond the scope of
this essentials course
bill wyman has of course your linda dot com
on building data driven applications with i_r_s_ that uses sequel liked
ten and twenty twelve watch this space for more on core data my clerk
so the next question has to be in for saving simple data
where we saving it too
now i a less does have a final system although it's not quite what you're used
to
you don't just have
free access to browse the file system like you might do on the desktop
your application
can only access it's little sandbox part of it
every application
gets its own documents folder as well as a library an attempt folder
but it's controlled by ohio west what that means is the path to this document
library
taken care of by the i_r_s_ operating system it's not obvious and it's not up
to you
you have to ask i a west to tell you what it is before you start to use it
so you can only reading right from your own area
and other applications
can only read and write from their state can't attach yours
there are few notable exceptions such as reading from the built-in address book
or from the ir called library or from calendar events but pretty much you're
limited to
just your own data
now the next question when do you say
we'd like to think that our application
special on the users will treat it kindly but the truth is that a moment
the user can hit the home screen button
and you're out is going to have to exit immediately they are not
going to hit the save button
they're going to leave
and you're going to need to respond to that very very quickly
the perfect event when they leave the apt is not a bad cold
application did enter background in the uk delegate
and this will be called by ohio s
when something is trigger in your application to leave
and it has to leave immediately
singer application goes into the background and you've saved the day sir
when we open up the application again
when do you loaded
before restoring from the background the perfect place would be application will
enter foreground
to do the reverse of anything you did
an application did enter background and neither of these would be the time and
place
to pop up
you weiler views and ask questions it's the time to get out
get as quickly as possible
or get back and running as quickly as possible
and with these things in mind
we can go on and see an example of saving data on iowa's device