Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating the preferences plist in Xcode

From: iOS SDK and SQLite: Building Data-Driven Apps

Video: Creating the preferences plist in Xcode

Oftentimes an application needs a simple way of allowing users to choose some default values for settings. You can do this with a modal dialog if you have enough of a settings requirement to justify the coding in UI investment. The simple solution, however, is to use the iOS settings interface. Here, we have our BW RSS application so far, running on the iOS Simulator. And because again, the small screen that I'm working on the iOS simulator has no border, and it has no Home button.

Creating the preferences plist in Xcode

Oftentimes an application needs a simple way of allowing users to choose some default values for settings. You can do this with a modal dialog if you have enough of a settings requirement to justify the coding in UI investment. The simple solution, however, is to use the iOS settings interface. Here, we have our BW RSS application so far, running on the iOS Simulator. And because again, the small screen that I'm working on the iOS simulator has no border, and it has no Home button.

So, if I want to press the Home button, I press Shift+Command+H on my keyboard. So if I want to change the settings, I need to press the Home button and run the Settings application and scroll down here till we see our BW RSS application, and there's the Settings. So, I can set the maximum items per feed, and I can see the version number. This is a very simple usage of the settings. So, if you have just a few things to set, or if you want to display a version number or something like that, Settings is a common way to do this.

So, I'm going to quit the simulator for now, and we're going to come in here to our BWRSS-preferences-start, and I'm going to make a working copy, and I'm just going to rename this to BWRSS preferences. We're not going to have a separate version for a later movie. And I'm going to launch it in Xcode by double-clicking on the Xcode project file. So, I'm going to go ahead and open up this disclosure triangle, and I'm going to set the iPhone Simulator.

Under Supporting Files here, we don't yet have it, but we're going to create a settings bundle. So, I'm going to right click on Supporting Files, and I'm going to say New File and under iOS, Resource, I'm going to select Settings Bundle and press Next. Now, you want to leave this default name because that's important. It won't work if it's named something else, and you wanted in the Supporting Files Group and in your BWRSS targets.

So I'll press Create, and now we have our settings bundle. So, I'm going to go ahead and open that disclosure triangle there, and I'm going to select the Root.plist, and that's where we actually are able to set the preferences. You'll notice that there's a disclosure triangle here next to this thing called Preference Items, and there is four items in there and those are just examples, and we're not actually going to use those. You see, this interface is really weird. When you click on stuff, stuff happens, and you sometimes have to press Escape.

So, I clicked on that and then I pressed Escape. I'm going to press my Delete Key here on the keyboard and just delete those three items and then I'm going to come back up here to Item 0 (Group - Group), and I'm going to open it up and under Title, I'm going to call this, Feed Settings. So, I'll select this over here, and I'll type Feed Settings, and we're going to leave that one as group as Type for this Item 0. That fills out Item 0. Item 0 has a type of group, and it has a title of Feed Settings.

And then with this closed, I'm going to press the Enter key, and it will create a new item. I'm going to press Escape, and I'm going to press Enter again, I'm going to do that several times until I get four items here. So, I have three new items under Item 0 Group, and we're going to fill these in. The first one, Item 1, its type is going to be Multi Value. So, under Type, you'll notice that the arrow is way over here. I can select that and say Multi Value and its title, I'll double-click in that space there for the title is Max Items Per Feed, like that.

It also gets an Identifier, and that's going to be max_items_per_feed, and you notice it's an identifier. It's going to be referenced from the code, so I don't want spaces in, and I'm using underscores. It's going to get a few more things, so I'm clicking over here on the left because that seems to be a fairly safe place to click, and I'm going to press the Enter Key, and I get a new item. This item is going to be a default value so that's correct, and its type is going to be a number.

And over here, I'm going to double-click on that number it'll allow me to edit it, and that's going to be 50. So, it's going to have a default value of 50. And when I press Enter, this editor is just really weird for these types of items, so you have to bear with it a little bit. So, that's default value. And then we're going to have a new item called Titles, and I'm just going to close that real quick and make another one and a new item called, Values. So, it actually defaults to the correct thing here, and if it doesn't, you can always press that little arrow to the right of the field that you want to change, and you get an opportunity to change it.

So under Titles, there's going to be four items. Again, cursor jumps around, two, three, and four. Under values, there's going to be four items. So, I open that up, and I have one, two, three, and four. All of these values are going to be type Number. So we'll just go ahead and change those right now. And their values are going to be 25, 50, 100, and 250.

And then the titles for each of these items are going to be Strings and they're just going to say the same thing, 25. I guess I could spell it out if I wanted to. So, these will be the labels that will be next to each of these values, 250. We'll see how these looks like in the Settings app in a little bit here. So, there is our titles and our values, and that's Item 1 Multi Value. Item 2 is really just a spacer. It creates an empty space.

So, its Type is a Group and its Title is blank, and there is no key, so I'm just going to delete that one. Item 3, its Type is Title, and its Title is Version, its Identifier is BWRSS_Version like that with an underscore, and it's going to have a Default Value, and we'll just give it a version value here, 3.1.0, and there, we're done.

So, I'm going to press Command+S to save this. Now again, to press the Home button, I'm pressing Shift+Command+H, and I'm going to come out here to the Settings. I'm going to scroll down here, and there is our BWRSS, and there we have our Max Items Per Feed, which we can change, and we have our Version, which when we click on this, nothing happens. And you see our title there, it says Feed Settings. So, that's all of these things here. So now that we have a working settings bundle, we need to be able to read these values in our code.

And we'll take a look at how to do that in the next lesson.

Show transcript

This video is part of

Image for iOS SDK and SQLite: Building Data-Driven Apps
iOS SDK and SQLite: Building Data-Driven Apps

41 video lessons · 6445 viewers

Bill Weinman
Author

 
Expand all | Collapse all
  1. 8m 29s
    1. Welcome
      57s
    2. Exercise files
      2m 17s
    3. Course overview
      3m 4s
    4. Application overview
      2m 11s
  2. 14m 49s
    1. Prototyping in a testbed
      1m 27s
    2. Building the view controller
      3m 45s
    3. Coding the testbed
      7m 56s
    4. Using the testbed
      1m 41s
  3. 37m 49s
    1. Understanding SQLite in iOS
      1m 41s
    2. Creating an Objective-C interface for SQLite
      9m 57s
    3. Testing the BWDB interface in the sandbox
      7m 1s
    4. Designing a database schema
      8m 7s
    5. Supporting the application with a specific interface
      7m 7s
    6. Using C pointers with automatic reference counting (ARC)
      3m 56s
  4. 21m 18s
    1. Understanding the table view
      1m 33s
    2. Creating the view controller
      6m 39s
    3. Reading from the database
      13m 6s
  5. 33m 50s
    1. Understanding the parsing process
      1m 57s
    2. Creating the item view controller
      12m 25s
    3. Reading data from the internet
      5m 30s
    4. Parsing the feed with NSXMLParser
      8m 2s
    5. Updating the item view with the feed items
      5m 56s
  6. 40m 14s
    1. Understanding the modal view
      1m 47s
    2. Constructing the view controller
      15m 5s
    3. Finding a feed link in a web page
      8m 55s
    4. Parsing the feed with NSXMLParser
      5m 4s
    5. Delegating back to the parent view
      6m 11s
    6. Deleting feeds
      3m 12s
  7. 21m 5s
    1. Creating the web view class
      12m 33s
    2. Coding the web view
      5m 25s
    3. Viewing pages in Safari
      3m 7s
  8. 14m 3s
    1. Understanding the iOS preferences system
      1m 23s
    2. Creating the preferences plist in Xcode
      7m 20s
    3. Reading preferences in your application
      5m 20s
  9. 6m 15s
    1. Adding pull-to-refresh functionality
      2m 34s
    2. Implementing the pull-to-refresh gesture for iOS 6
      3m 41s
  10. 27m 1s
    1. Understanding split view
      1m 4s
    2. Coding the table views
      11m 24s
    3. Implementing the iPad detail view
      6m 35s
    4. Implementing the iPad modal view
      7m 58s
  11. 35s
    1. Goodbye
      35s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed iOS SDK and SQLite: Building Data-Driven Apps.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.