Apple Health Frameworks

Nov 29 2022 · Swift 5, iOS 15, Xcode 13

Part 3: Take Advantage of CareKit & ResearchKit

17. Make a Contact Page

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 16. Save Body Temperature Using HealthKit Next episode: 18. Take a Deep Look Into the CareKit

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 17. Make a Contact Page

Part 3, Episode 17, Use CareKit to make a contact page

In this episode, I want to show you how to use another feature from CareKit, which allows you to have a contact page inside your app for quick access if your user needs to contact you.

Let’s make one last feature done together, Open SceneDelegate from Project Navigator right after // Create Contact Page add these codes:

    makeContacts()
    let contactViewController  = OCKListViewController()
    contactViewController.appendViewController(OCKDetailedContactViewController(contactID: "contact.emad", storeManager: storeManager), animated: false)
    contactViewController.title = "Contact"
    contactViewController.tabBarItem = UITabBarItem(
      title: "Contact",
      image: UIImage(systemName: "list.bullet"),
      tag: 1
    )

Here you used the prepared function to make the contacts and store them in the StoreManager. Next, you initiate an OCKListViewController and then append one OCKDetailedContactViewController and use the contact id I prepared for you on that function. The last thing is you styled it. Now it’s time to use that ViewController inside of the tab bar.

    let contactTab = UINavigationController(rootViewController: contactViewController)

Here, you create a navigation controller and add the contact view controller as a root.

    rootController.setViewControllers([planTab, overviewTab, contactTab], animated: false)

Furthermore, you modify the list of tabs by adding the contact tab. If you scroll to the end, you see what I prepared for you; it’s an OCKContact object with some information as input.

Build and run the project and navigate to the contact tab to see what you’ve made. If you want to see another style of Contact page, you can easily change the viewController type from OCKDetailedContactViewController to the OCKSimpleContactViewController and then build and run the project to see does this looks; I like this one better because it’s more Apple style :)