Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
iOS 10 Programming for Beginners

You're reading from   iOS 10 Programming for Beginners Explore the latest iOS 10 and Swift 3 features

Arrow left icon
Product type Paperback
Published in Dec 2016
Publisher Packt
ISBN-13 9781786464507
Length 678 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Craig Clayton Craig Clayton
Author Profile Icon Craig Clayton
Craig Clayton
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Getting Familiar with Xcode FREE CHAPTER 2. Building a Foundation with Swift 3. Digging Deeper 4. Digging into Collections 5. Starting the UI Setup 6. Setting Up UI 7. Getting Started with the Grid 8. Getting Started with the List 9. Working More with Lists 10. Where Are We? 11. Where's My Data? 12. Foodie Reviews 13. Saving Reviews 14. Universal 15. iMessages 16. Notifications 17. Just a Peek 18. Beta and Store Submission Index

Adding favorites

A nice feature for our app would be to use 3D Touch to allow users to add favorites within our Restaurant List View. We already have the heart in our Restaurant Detail page. Therefore, let's add 3D Touch to the heart to add favorites. This is how we want it to look when we are finished:

Adding favorites

First thing we need to do is add a new model object so that we can save our restaurant favorites to Core Data.

Creating a new model object

  1. In the Navigator panel, open the LetsEatModel.xcdatamodeld file that can be found in the Core Data folder in the Common folder.
  2. Make sure that you have the Graph Style selected:
    Creating a new model object
  3. Click on the + button for Add Entity and, then, double-click on the text, Entity, and update it to Favorite:
    Creating a new model object
  4. Next, ensure that the Favorite Entity is selected and click on the + button for Add Attribute:
    Creating a new model object
  5. In the box, in the center of the screen, under Attributes, you should now see the word attribute. Double-click on attribute and change it to restaurantID:
    Creating a new model object
  6. Next, select the Favorite...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime