Online Book Reader

Home Category

Learn Objective-C on the Mac - Mark Dalrymple [93]

By Root 974 0
Buttons checkbox, then click Next. Then, in the list of properties to include, click to turn off quotes, leaving just name enabled, and click Finish. In the new GUI that’s created, select and delete the Fetch button. The new GUI is placed directly in the center of the window; drag it upwards, into the upper half of the window.

NOTE: If you’re using Leopard, the auto-generated nib file has its # out of # textfield somewhat out of place, tucked away behind the table view, so you’ll need to dig it out if you want to see it in the GUI. Select the table view, then select Layout➤Send To Back from the menu, then drag the # out of # textfield down to line it up with the other buttons.

Now do the same set of things for the Quote entity, dragging it to the window as well. When it comes time to select properties to include, turn off show, leaving character and quoteText enabled. Everything else should be done just the same. After the GUI has been created, drag the new box down a bit so you can see both sets of views. Figure 9- 3 shows what the window should look like now.

Figure 9-3. This chapter’s assisted GUI creation

Smoothing Out the Rough Spots


Now we’re going to rearrange things a bit so that our window looks a little more orderly, and configure the array controllers so that the display of quotes is dependent on the selected show. Start by dragging the NSBox labeled Quote from the other window into position below the Show box, using the blue guidelines to help align the two. Then, select the window by clicking its title bar, and make it just the right size to show its content by selecting Layout➤Size To Fit from the menu, ending up with the much more compact result shown in Figure 9-4.

Figure 9-4. The data entry window for QuoteMonger

Complete the window configuration by opening the Attributes Inspector and setting the window’s title to Data Entry.

Now, let’s configure the array controllers a bit. Like before, our friendly assistant has given them some unwieldy names, Show Array Controller and Quote Array Controller. Edit each of those in the main nib window, changing them to Shows and Quotes, respectively. Now, select the Quotes controller, and open the Bindings Inspector. By default, each array controller will fetch all objects for the corresponding entity. We’re going to change this one to only fetch quotes based on the selected Show. Open the Content Set binding, select Shows in the popup list, selection in the Controller Key combo box, and type in quotes in the Model Key Path combo box. Finally press Return to turn on the binding.

Enter Some Initial Quotes


Save your changes, switch back to Xcode, and click Build & Run. The app should start up and show you the Data Entry window. Select the Add button below the upper table view to add a show, and double-click in the highlighted space in the table view to edit the show’s name. Do this a few times to create a few Show instances. Now, with one of the shows selected, add a quote in the lower table, editing the text and the names of any characters right into the table. If you add a quote that contains an exchange between two or more characters, enter the names of all involved characters in the Character field. When we later enable search based on character names, it will work with all the names you entered. Add a few more quotes, spread across a few different shows. You’ll see that the list of quotes changes when you select a different show, and if you quit and restart QuoteMonger, you should see that everything you entered has been saved.

Creating the Quote Finder Window


Now it’s time to lay the foundation for the search window. Once again, we’ll use our friendly assistant to start things out, but from then on we’ll be making lots of changes. Back in Interface Builder, find the window that was left empty after its contents were moved to the other window and bring it to the front. Then go back to Xcode again, and -drag the Quote entity back to the empty window in Interface Builder. Select Master/Detail View (just like we always do),

Return Main Page Previous Page Next Page

®Online Book Reader