Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The first step in building our Testbed is to create the view controller in interface builder. So let's create a project in Xcode and get started. Let's start up Xcode here and under the File menu I'm going to select New > Project. Under iOS and Application I'm going to select Single View Application and press Next. The Name of our project will be Testbed, and I leave the Organization Name alone. Company Identifier, example.com, you'll notice that's in reverse domain notation, and you'll just use your own domain name, or you'll make something up for it.
Our Class Prefix is Testbed, that's used for building the Class Names and Devices just the iPhone, and we're going to Use Storyboards, Use ARC, and we do not need Unit Tests for this, so I press Next. This is in our exercise files Chap01 and Create, and there is our Testbed application. So before we can create the view controller and interface builder we need to create an outlet in the code.
So I'm just going to go into the code here, and I'm going to close that on the right so we can see the code. I'm in the .m File because we're going to create the outlet as part of the private interface, that's because we don't need it exposed to the public, there is no property, and it's not in the header file, it's just going to be right here in the .m file. Under interface I am going to put in some brackets and create the outlet right here. IBOutlet UITextView, because this is going to be a text view, ViewController and an asterisk to make it a pointer because objects in Objective-C are Pointers, and I'm going to call it TextView like that and a semicolon and pressing Command+S on my Mac keyboard to save this, and we're done.
You notice it creates this little circle over here that we're going to use as an outlet, and we'll get to that in a moment. Now I'm going to up here to the Storyboard, and you'll notice--I'm just going to minimize this controller thing over to the left there because we have limited real estate here on this display for the purpose of the recording--you'll notice down here at the bottom it says Testbed View Controller. I'm going to bring the inspector back on the right and show the attributes Inspector. You notice there's nothing there yet because I haven't selected anything yet.
Under my objects here, so you want to make sure that your Objects tab is selected, under Objects I'm going to select Data Views, that's what we want. We want the TextView, which is right here, I'm going to grab a TextView, and I'm going to drag it on to my View Controller and just get it all lined up just right there. And now under my Inspector you'll notice that it's got text in it, so I'm just going to select all of that and delete it. I'm going to press Enter on my keyboard, and you see all that text goes away in the View.
I am going to uncheck Editable because we don't need this to be actually Editable. Now I'm going to bring up my Assistant editor, and you'll notice that it brings up the TestbedViewController.h. We actually want the .m file so I'm going to select the .m File here because there is outlet, and I just drag that over to the View Controller, and we're done. So the View Controller now, if I select my View Controller and go over here to the Inspector, you'll see that my TextView is in the Referencing Outlets, and that's exactly what we want.
So now we've created the View Controller and all that's left is to plug in the code to make it work. So I'll save this, and we'll plug in the code in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97179 Viewers
61 Video lessons · 84468 Viewers
71 Video lessons · 68676 Viewers
56 Video lessons · 101160 Viewers
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.
Your file was successfully uploaded.