xCode Workshop 4 – Adding Items to Checklist

Building from last week’s checklist application, today in the workshop it was all about adding new items to the list and inserting in an input menu where users would type out their new objects. Building from the application we built last week, below is the process that was used.Screen Shot 2015-02-19 at 15.02.21

The first stage was to create a new ‘View.Controller’ to hold the input menu where users would add the new item to the list. A ‘Bar Button Item’ in the ‘Main.Storyboard’, was added, which behaves similarly to a button, and has a title, action and target, however this class also provides methods you can use to specify it with a system provided image that is recognisable from the iOS 8 UI kit.

The next stage was to create the text field so the user can input text and use the ‘Done’ button to update the table with the new item and use the ‘Cancel’ button to not save any changes that have been made and dismiss the ‘View.Controller’ menu. This was done using delegates to transfer the data from one ‘View.Controller’ to another. For ‘Done’ a new ‘ChecklistItem’ is created with its name property set to the value of the text field. The delegate is then called and passes it to the new item. For ‘Cancel’, it simply calls the delegate cancel function which dismisses the ‘View.Controller’ menu.

Screen Shot 2015-02-19 at 15.41.55

Screen Shot 2015-02-29 at 15.42.10

 

 

 

 

For the last stage a ‘protocol’ was created. This is the declaration of the method the delegate promises to implement, one if the user cancels and one if the user confirms.

Screen Shot 2015-02-19 at 15.42.20

After completing this workshop I feel much more comfortable with the idea of delegates and how they are use to move data from one controller to another.

Below is the finished application as a demonstration:

Advertisements

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