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.
At this point we have built the text view in the interface builder, and we just need to plug in the code to make the testbed work. The results of what I did in the previous movie are in this Testbed-02-done folder, and that's actually our project folder. And so I'm going to take that folder, and I'm going to copy it, and I'm going to paste it into this Chapter 1 folder, and I'm just going to rename it to Testbed-O3, because this is Movie 3 in this chapter. And I'm going to open the project by double clicking on Testbed.xcodeproject.
And that will invoke Xcode, and it will open the project. And I can navigate over here to Testbed View Controller.m, and I'm going to close the Inspector pane. I'm actually going to close the Assistant Editor as well and just come over here to the Plain Editor, and that gives the maximum amount of room. You're on this limited real estate. You can leave all that stuff open if you like on your screen, because you probably have a lot more room on your screen than I do.
So, this is our whole view controller class here. And so, the first thing I'm going to do is I'm going to bring in some library code from our exercise files. So under Libraries here, I'm going to grab this BWUtilities folder, and I'm just going to drag it over here into our project. You see I'm dragging it where it says Testbed, not in any of these other places just right there in that Testbed folder, and I'm going to let go of it. And you'll notice here in Xcode, I get this little dialog box. I want to make sure I select copy items, and create groups for any added folders and Add to targets has to have Testbed checked.
So, what that does is that it copies the libraries from BWUtilities folder into our project. If I don't have this checked, then it won't copy, it will just use it in place, and that's not really what we want. We want to copy it into the project, and I Create groups for any added folders, and you'll see what that will do here in a moment. It will create a group that looks like a folder in this display here. And Add to targets means it is going to get compiled into this Testbed target, and we need that in order to be able to use the code.
So, I'm going to say Finish, and there's our BWUtilities folder and just has this BWUtilities.m and BWUutilities.h. And all this is a few functions that are useful for our Testbed. Here's the message function and our alert message so we can display alerts, flattenHTML trim string. These are things that we use throughout the project. We're also going to use them in the final RSS reader project, or at least some of them. And then in the h file, we have our interface.
Now, it's not actually a class in the strictest sense. It's not using object oriented techniques, these are all individual functions, because they are actually more useful that way, and the way that we are going to be using them. But the h file exposes this interface to rest of the codes so that we can actually use the functions in the .m file. So, I'm going to close that group. So, that's the group that we created. It looks like a folder in this interface, but it's actually called a group. Now I'm going to come over here in the TestbedViewController.h, and I'm going to come down here, and I am going to say import and in the double quotes I'm going to say, "BWUtilities.h", and you see the code completion is right there already.
And I'm also going to come down here, and I'm going to create a static string. And I'm going to make it constant. I'm going to call it kTestbed. So, using a k at the beginning of a variable name means it's a constant. That's a convention that's often used in Objective-C. And kTestbedVersion equals and 1.0, and a semi-colon. I'm going press command S to save this file and then I'm going to switch to the .m file.
So now, we've included our utilities when we created a string for our version. And under viewDidLoad here, I'm going to just start adding a little bit of code. First time I'm going to declare an external variable, extern, and it's a UITextView, and it's a messageTextView. And you'll notice that that variable is actually declared in our BWUtilities.h, and there it is. So, what I'm going to do is I'm going to populate that variable so that the utilities knows where our TextView is so that it can display stuff in our TextView.
So, I'm going to say, messageTextView = textView. So, that tells the BWUtilities where our textView is so that it can actually post messages to it. And I'm going to set the font in our textView, so it sets it to a system font of size 12. And I'm going to run a function called RunTest, which we have not declared yet. So, I'm going to say self runTest.
And we're going to get a littler error here, because it's not declared yet, and I'm going to come up here above it, and I'm going to declare it. I'm going to say (void) runTest, and now, we don't have an error down here anymore, because we have a function called runTest. In our runTest, I'm going to display a message, and it is going to say Testbed version, and I'm going to use our kTestbedVersion variable there. So, the message function actually is variadic function, it works just like printf does.
You'll notice here in the code it actually calls format. So, it's a variadic function, it has va_list and va_start just like a normal variadic function in C and feel free to check out my C and C++ Essential Training for tutorial on how variadic functions work. And here, it uses NSString initWithFormat, which is very much like format using C, and it passes at the argument so that it works like a normal variadic function. So, that allows me to do things like this %@ to display Objective-C object.
So now, we're going to display a series of strings like this. And this is using the new Objective-C literal object syntax. So, this is called a boxed array, and it's a much easier way to declare an array than the old way. So, I can just declare a bunch of strings in here in this array like that, and then inside in each of the strings I can put some text.
So now we have our little runTest function. It will display the TestbedVersion, and that constant is declared in our .h file, and it steps through this boxed array and displays each of these strings individually. So, when I save this, and I'm going to make sure I've selected the iPhone 6.0 simulator and press Run. It will go ahead and compile it, Build Succeeded, and it will bring up the simulator, and there it is it's running.
And you'll notice that these messages are now displaying in our text view. So now, we have a working iOS testbed. I find this a very valuable tool. Whenever I have a specific task to accomplish, I'll start with the testbed like this one, and I'll do some prototyping to try out different approaches and decide on a strategy. This saves me a lot of time and headache that I would otherwise spend trying to debug a new idea while it's intermingled with other working code. We'll see an example of how to use this in the next movie.
Find answers to the most frequently asked questions about iOS SDK and SQLite: Building Data-Driven Apps .
Here are the FAQs that matched your search "" :
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.
"Used type va_list (aka_builtin_va_list) where arithmetic or pointer type is required"
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.