DPS923 MAP523 Lab 5

Based on the last lab/assignment, add new features: ‘Add item’, and delete item.

.

(this document is being edited, and this notice will be removed when the edits are complete)

.

DPS923 MAP523 Lab 5 – due Friday, February 28, at 11:00pm

Due date: Friday, February 28, at 11:00pm ET

Grade value: 4% of your final course grade

.

Objective(s)

Implement the ‘add item’ coding pattern, by adding on to your Lab 4 work

Enable table view editing (which really means ‘delete’)

.

Introduction to the problem that you will solve

Your work on Lab 4 – “Core Data Intro” – enabled you to get started with Core Data and a navigation-based app.

For this assignment, you will add two new features – ‘add item’, and table view edit (item delete).

Enjoy!

.

Specifications

Use your existing project from Lab 4, Core Data Intro, as the ‘template’ for your app. Follow the procedure to rename your app to Canada.

Next, you will perform these tasks:

  1. Create a new controller to enable ‘add item’
  2. Create a new scene/view for this new controller
  3. Modify your <something>List controller to work with the new ‘add item’ controller
  4. Add a Manager class method to support ‘add item’ task
  5. Modify your <something>List controller to enable table row delete
  6. Add a Manager class method to support ‘delete item’ task

.

(point form instructions for now – will be filled in soon) 

.

Create a new controller to enable ‘add item’

In Lab 4, if you decided to display a list of provinces, then create a new UIViewController subclass named EditProvince.

Alternatively, if you decided to display a list of cities, then create a new UIViewController subclass named EditCity.

Your new view controller will declare a protocol. Use the coding technique you first learned in Week 5 (February 3 notes, “Modal view, creating our own” topic; and in the “To Do Add” code example on GitHub).

Before you call back to the delegate method, you should perform simple data validation.

.

Create a new scene/view for this new controller

On the storyboard, add a new (View Controller) scene.

Configure its identity, and its user interface with controls that enable data gathering from the user. Connect the user interface to outlets in its controller.

On the existing table view scene, add a Bar Button (configured as “Add”) to the right side of the nav bar. Connect it, using a modal segue, to the new scene you just added above. Make sure you set the segue’s identifier to an appropriate value.

.

Modify your <something>List controller to work with the new ‘add item’ controller

In your <something>List controller, you have to adopt the protocol you declared in the new controller.

Next, add another ‘if’ code block to prepareForSegue:sender: to handle the nav bar button action. It’s a best practice to pass on a reference to the app’s model object. (We will not need it for this lab/assignment, but we will for future work.)

Then, implement the protocol method. It will call a method in the app’s manager object, and pass on the data gathered from the user. In the next step, you will code the Manager class method.

.

Add a Manager class method to support ‘add item’ task

A new method in the Manager class will support the ‘add item’ task.

The design is flexible. You can accept any of these as argument(s) to the method:

  • Individual data elements (strings, numbers, etc.)
  • A dictionary object (NSDictionary)
  • A Province or City object (as appropriate for your app)

This method must also save changes to the store.

.

Modify your <something>List controller to enable table row delete

Modify your <something>List controller to enable table row delete.

You first saw this pattern in Week 6 (February 10 notes; and in the GitHub examples).

In code, add a button to the left side of the nav bar to enable editing.

Next, write the method to handle the delete request. It will call a method in the app’s manager object (which you will write next).

Then, handle the visual appearance by implementing the smooth animated row delete action.

.

Add a Manager class method to support ‘delete item’ task

A new method in the Manager class will support item delete.

It will accept a Province or City object (as appropriate for your app). Then, it will delete the object, and save changes in the store.

.

Submitting your work

Follow these instructions to send me your work:

  1. Make sure your project works correctly
  2. Locate your Canada project folder in Finder
  3. Right-click the folder, and choose Compress “Canada”, which creates a zip file (make sure the zip file is fairly small, around 500KB or less)
  4. Login to My.Seneca, and in this course’s Assignments area, look for the upload link, and submit your work there

.

.

.

.

.

.

.

.

.

.

.

.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: