Book Image

Mastering iOS 12 Programming - Third Edition

By : Donny Wals
Book Image

Mastering iOS 12 Programming - Third Edition

By: Donny Wals

Overview of this book

The iOS development environment has significantly matured, and with Apple users spending more money in the App Store, there are plenty of development opportunities for professional iOS developers. However, the journey to mastering iOS development and the new features of iOS 12 is not straightforward. This book will help you make that transition smoothly and easily. With the help of Swift 4.2, you’ll not only learn how to program for iOS 12, but also how to write efficient, readable, and maintainable Swift code that maintains industry best practices. Mastering iOS 12 Programming will help you build real-world applications and reflect the real-world development flow. You will also find a mix of thorough background information and practical examples, teaching you how to start implementing your newly gained knowledge. By the end of this book, you will have got to grips with building iOS applications that harness advanced techniques and make best use of the latest and greatest features available in iOS 12.
Table of Contents (35 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
Index

Requesting a user's location


As you can imagine, giving an application access to your exact location is quite a big deal. In the wrong hands, this data could allow people with malicious intentions to know exactly where you are at any given time, and abuse this knowledge in many different ways. For this reason, it's essential that you only request a user's location if you absolutely have to. Simply using it for a small feature, or to make sure a user is in some arbitrary location before they sign up for a service, might not always be a good enough reason to ask for a user's location.

Asking for permission to access location data

When you do need access to a user's location, you have to ask permission first. Similar to how you have to add a reason for needing the camera or a user's contacts to the Info.plist file, you must also provide a reason for requesting location data. In the case of location data, there are two keys you can add to the Info.plist:

  • Privacy-Location When In Use Usage Description...