Book Image

iOS Programming Cookbook

Book Image

iOS Programming Cookbook

Overview of this book

Do you want to understand all the facets of iOS programming and build complex iOS apps? Then you have come to the right place. This problem-solution guide will help you to eliminate expensive learning curves and focus on specific issues to make you proficient at tasks and the speed-up time involved. Beginning with some advanced UI components such as Stack Views and UICollectionView, you will gradually move on to building an interface efficiently. You will work through adding gesture recognizer and touch elements on table cells for custom actions. You will work with the Photos framework to access and manipulate photos. You will then prepare your app for multitasking and write responsive and highly efficient apps. Next, you will integrate maps and core location services while making your app more secure through various encryption methods. Finally, you will dive deep into the advanced techniques of implementing notifications while working with memory management and optimizing the performance of your apps. By the end of the book, you will master most of the latest iOS 10 frameworks.
Table of Contents (22 chapters)
iOS Programming Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Memory management with ARC


In this recipe, we will talk about memory management in iOS using ARC (Automatic Reference Counting). ARC was first introduced in iOS 5 to help developers to manage the app memory. However, while ARC takes care of releasing objects, you still have to set up your reference types correctly to avoid any leaks and retain cycles. In the following recipe, we will try to build a simple app that has a lot of memory issues, and we will see how to catch these issues and what the correct ways to solve them are.

Getting ready

There are some definitions and concepts about memory management that you need to know before starting our demo. In iOS, each object has a reference count in memory, and once this count reaches ZERO, the object will be deallocated from memory. The reference count of any object refers to how many objects have a strong reference to that object. This reference sends a retain message to that object to increase its reference count by ONE. Once any object is done...