iOS SDK and SQLite: Building Data-Driven Apps
Illustration by Don Barnett

Implementing the iPad modal view


From:

iOS SDK and SQLite: Building Data-Driven Apps

with Bill Weinman

Video: Implementing the iPad modal view

Now that we have a working groupView, itemView, and webView, it's time to implement our addView. The tactic is pretty simple. We're going to create the controller in the storyboard, connect it to the BWRSSAddViewController class, and set up the form elements. Let's start by making a working copy of BWRSS- splitview-03, and I'm just using this done version, you can use the version that you created in the last lesson if you're following along. I'm just going to rename it to BWRSS-splitview-04, and I'm going to open it in Xcode by double-clicking on this Xcode project file.
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 your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course iOS SDK and SQLite: Building Data-Driven Apps
3h 45m Intermediate Jan 16, 2013

Viewers: in countries Watching now:

The iOS software development kit (SDK) includes the popular SQLite library, a lightweight yet powerful relational database engine that is easily embedded into an application. In this course, Bill Weinman teaches you how to build an RSS reader for iOS devices, integrating XML data and a streamlined interface. He explains how to use the SQLite database, display information in a table view, code view controllers, and create a preferences pane for your app. The resulting application is optimized for all iPhone and iPad displays.

Topics include:
  • Prototyping the app
  • Coding and working with a testbed
  • Creating an Objective-C interface for SQLite
  • Designing a database schema
  • Creating the view controllers
  • Reading and writing to the database
  • Parsing the RSS feed with NSXMLParser
  • Updating the item view with feed items
  • Implementing the pull to refresh gesture for iOS 6
  • Creating a universal application with multiple views
Subject:
Developer
Software:
iOS
Author:
Bill Weinman

Implementing the iPad modal view

Now that we have a working groupView, itemView, and webView, it's time to implement our addView. The tactic is pretty simple. We're going to create the controller in the storyboard, connect it to the BWRSSAddViewController class, and set up the form elements. Let's start by making a working copy of BWRSS- splitview-03, and I'm just using this done version, you can use the version that you created in the last lesson if you're following along. I'm just going to rename it to BWRSS-splitview-04, and I'm going to open it in Xcode by double-clicking on this Xcode project file.

So now we're going to come up to the iPad storyboard, which is right up there, and I'm going to open up our Utilities View and scroll over here. You see we have the Items Table View Controller right there, and right under it I'm going to go ahead and put our Add View Controller. So, the first thing I'm going to do is I'm going to add that button up here on our Feeds Table View Controller. So, come over here to Objects and Windows & Bars and grab a Bar button Item and just drop it right there and call it an Add button so it gets that little Plus and Command+S to save.

Now, under our Items View Controller, I'm just going to scroll on over here, and I'm going to create a new controller. This is just a plain View Controller, so I'm going to drop it in right here and its size is going to be Form Sheet so that makes it manageable right there and drag it down over here. The Transition Style will say Cover Vertical. The Presentation will say Form Sheet.

And then we're going to set our controller to the BWRSSAddViewController, and I'm pressing Command+S to save. Now, I'll scroll down here so we can see a little bit more of it, and under Data Views I'm going to grab a Scroll View, and I'm going to drop that right here on this controller like that. Get it all nice and lined up, and over here, in the Attributes Inspector, let's scroll down and give it a background of Scroll View Textured Background Color.

Now, the rest of this is going to be very much like what we did when we first created the addView controller for the iPhone. We can go ahead and populate this view. I'm going to start with a text label up here at the top, and I'll stretch that out to sides using these handy dandy guides that the Interface Builder gives us. I'm going to make it centered and make it the System Bold Font 17 size.

It's going to say Add RSS Feed, like that, and then I'm going to make it white. This background is actually dark. It doesn't look like it's dark, there it is. But you'll see when we run it in the Emulator that it actually is dark. Now we can grab another text label and put it right under this one, and we're going to leave this one left flush, and this is our Status Label, and it's going to say Enter a URL.

This one is going to be Size 12, and it's also going to be white. Now, we're going to grab a text field and put that right under that other text label and bring that over to the sides and the text in there will say http://, and we're going to scroll down here and set some properties here, Capitalization: None, Correction: No, Keyboard: URL, Appearance: Default, and Return Key: Done. So, now I'm going to grab a couple of buttons here, Round Rectangle Buttons, and I'm going to drag them over here and align them up.

This little technique for doing this, and I'm going to grab them both and center them, and then the button on the left will be called Cancel, and the button on the right will be called Add. Now, we're going to connect our segue, and that will be a little bit challenging with this being zoomed in like this. Let's see if we can do this with it zoomed out. I'm not sure that it will let me. I'm going to Ctrl-click on this button and drag it over here.

For Action Segue, I'm going to select Modal, and then I'm going to select our Segue like this and the Identifier is SegueToAddView, like that. Presentation is just Default, Transition is also Default. Style is Modal, that's great. Now, we're going to come down here where we're going to connect our Controller. I need to zoom back in apparently.

So, I'm going to Ctrl-drag from here down to the Add View Controller, and we'll select addAction and the cancelAction, and do the same thing again and select cancelAction. That works. Now, when I select this controller, we should see those hooked up properly, they are, excellent. The URL text field should come over here and the Status Label will come over to this one here.

You can almost see that it's the second one. It's not the top one, it's the second one. And then finally, we want to drag this text field, we want to drag it down into our ViewController and where it says the Outlet Delegate, we need to connect that up. So, here we have our delegate outlet on the text field is set to the Add View Controller, and if we come down to the Add View Controller, we see that our delegate is that text field.

So now, this should all be hooked up properly, I'm going to press Command+S to Save, and we're going to go ahead and run it in the iPad Simulator. I'm going to go ahead and put us in Landscape mode. We see there's our Plus button, I'll press that button, and there is our Add RSS Feed Controller. We can just type something in here, I'll put in wired.com and press the Add button, and there is our Wired Feed, and you see that's all working.

I can come back here again, I can add another one say arstechnica.com, and I can press the Done button. All of this works exactly like it does now in the iPhone version, and you notice we did no coding at all for this. All we did was hook up this new View Controller to the exact same code. So, this is a lot less work because we're able to leverage most of the work we've already done for the iPhone Form Factor. The Universal application model allows us to take advantage of two different platforms, two different sizes of screens, two different UIs, all with the same code base.

We now have a working storyboard interface that we can use for the Modal dialog box. With storyboard, this whole process becomes a whole lot easier. All we really need to do is set up the View Controller in the storyboard and connect it to our existing classes and then it just works. So, congratulations. You now have a fully-functional RSS Reader that runs in both the phone and tablet form factors.

Find answers to the most frequently asked questions about iOS SDK and SQLite: Building Data-Driven Apps .


Expand all | Collapse all
please wait ...
Q: Why is the RSSDB library in the exercise files different than the one in the videos?

A: The RSSDB library had to be updated to work around a bug in the iOS 7 SDK.

There is a bug in the iOS 7 SDK that prevents the BWDB fast enumeration implementation from working on a device. The symptom is code that runs fine on the emulator, but not on a device. iOS devices use an ARM processor, while the emulator runs on your Mac's Intel processor. This points to the LLVM ARM code generator as the source of the bug. Because the bug appears to be in the LLVM compiler, it may be some time before it is fixed.

As a workaround we have changed the getFeedIDs and getItemIDs methods in the RSSDB library so they don't use Objective C fast enumeration. 

Please note that this same bug also affects some of the BWDB testbed code in Chapter 2. The result is that it will run on the emulator but not on a device.

Q: After upgrading to Xcode 5.1 I get an error that says:

"Used type va_list (aka_builtin_va_list) where arithmetic or pointer type is required"

A: Please download the exercise files again to get the latest version of the BWDB library.
Q: I'm using Xcode 6. Why am I getting error messages with the exercise files?
A: A lot has changed in iOS since this course was released. The author is in the process of rewriting the code and updating the course for iOS 8. In the meantime he has prepared a version of the app that works in iOS 8 and Xcode 6. Download it here:
 
http://ios.bw.org/
 
 
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.

* Estimated file size

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 ?

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.