Objective-C Memory Management Essentials
eBook - ePub

Objective-C Memory Management Essentials

Gibson Tang, Maxim Vasilkov

Share book
  1. 200 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Objective-C Memory Management Essentials

Gibson Tang, Maxim Vasilkov

Book details
Book preview
Table of contents
Citations

About This Book

About This Book

  • Learn about the concepts of memory management in Objective-C
  • Get introduced to Swift, an innovative new programming language for Cocoa and Cocoa Touch
  • A step-by-step approach to various memory management techniques with lots of sample code and Xcode projects for your reference

Who This Book Is For

If you are new to Objective-C or a veteran in iOS application development, this is the book for you. This book will ensure that you can actively learn the methods and concepts in relation to memory management in a more engaging way. Basic knowledge of iOS development is required for this book.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Objective-C Memory Management Essentials an online PDF/ePUB?
Yes, you can access Objective-C Memory Management Essentials by Gibson Tang, Maxim Vasilkov in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781849697132

Objective-C Memory Management Essentials


Table of Contents

Objective-C Memory Management Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction to Objective-C Memory Management
Why do we need memory management in Objective-C?
An object's ownership and life cycle
Ownership of object and reference counting
What's a memory leak and why pay attention to it?
What is an object within Objective-C?
Summary
2. Automatic Reference Counting
What is ARC and how does it work?
How ARC looks
Project settings for ARC
A memory model in Objective-C
What you need to know about ARC and weak references
Summary
3. Using Autorelease Pools
Understanding the autorelease pool mechanism
Autorelease pool mechanism
Reducing peak memory footprint with autorelease pool blocks
An overview of Apple autoreleased classes
NSRunLoop
NSException
ARC and autorelease
Autorelease pool blocks and threads
Summary
4. Object Creation and Storage
Creation and initialization of objects
What is a class?
Classes
Object immutability
Object mutability
Inheritance
Convenience initializers
An Objective-C programmer's responsibility
The singleton pattern
Creating @property
Creating custom methods
String formatting
Summary
5. Managing Your Application Data
Device memory
Image optimization
Lazy loading
Control creation
Caching
SDWebImage
Object serialization
SQLite
SQLite versus Core Data
Summary
6. Using Core Data for Persistence
Why use Core Data?
Understanding Core Data concepts
Putting it into practice
Getting into the code
Saving data into the persistent store
Deleting data from the persistent store
Updating data
Summary
7. Key-value Programming Approaches
What is key-value coding or KVC?
The NSKeyValueCoding protocol
Compliance of attributes and one-to-one relationships
Compliance of indexed one-to-many relationships
Compliance of unordered many-to-many relationships
Advantages of key-value coding
Disadvantages of key-value coding
Manual subsets of NSKeyValueCoding behavior
Advantages of creating your own lookup path
Disadvantages of creating your own lookup path
Associated objects
Advantages of using associated objects
Disadvantages of using associated objects
Selectors as keys
Advantages of using selectors as keys
Disadvantages of using selectors as keys
Maximum flexibility and handling unusual keys/values
Advantages of doing your own implementation
Disadvantages of doing your own implementation
Key-value observing
Implementing key-value observing
Performance considerations
Summary
8. Introduction to Swift
Welcome to Swift
Basics of Swift
Variable declaration
Iterating statements
Conditional statements
Functions
Classes and structures in Swift
Closures
Memory management in Swift
Summary
9. Memory Management and Debugging
Memory leaks
Strong/weak references
Retain cycles
Memory overuse
Using the debugger and breakpoints
Collecting data on your app
Plumbing memory leaks
Using the LLVM / Clang Static Analyzer
Using NSZombie
Summary
10. Tips and Tricks for Memory Management
Objective-C, C, and memory management
Getters and setters
The property attribute in Objective-C
Performance guidelines
Don't overthink about memory management
When to avoid KVC and KVO
Summary
11. Features of Xcode 6
Introducing Xcode 6
What's new in storyboard
Allowing storyboard or the NIB file to replace launch images
Launching images from your app
Universal storyboards
Debugging in Xcode 6
Debug gauges
What's new in Interface Builder
Playground for Swift
Summary
Index

Objective-C Memory Management Essentials

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2015
Production reference: 1190315
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-712-5
www.packtpub.com

Credits

Authors
Gibson Tang
Maxim Vasilkov
Reviewers
Emil Atanasov
Christine M. Gerpheide
Commissioning Editor
James Jones
Acquisition Editor
James Jones
Content Development Editor
Amey Varangaonkar
Technical Editor
Vijin Boricha
Copy Editor
Janbal Dharmaraj
Project Coordinator
Leena Purkait
Proofreaders
Simran Bhogal
Maria Gould
Indexer
Hemangini Bari
Graphics
Sheetal Aute
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa

About the Authors

Gibson Tang grew up loving technology after getting his hands on an old Apple II when he was still a young kid. Since then, he has never stopped keeping pace with technology, and after he coded his first "Hello World" program, he has been hooked on programming ever since.
Following his studies at Nanyang Polytechnic and Singapore Institute of Management and serving a 6-year stint in the Republic of Singapore Navy (RSN), he honed his development skills creating software and games for Yahoo! and other Fortune 500 companies. In 2010, he founded Azukisoft Pte Ltd in Singapore to focus on mobile application development. Since then, he has developed countless mobile applications and games for start-ups and big companies both in USA and Singapore.
Apart from programming, he indulges in various hobbies such as soccer, computer games, and jogging in order to get his regular dose of Vitamin D and to see the sun once in a while. Occasionally, he would be on Steam or Battle.net blowing off some steam by slaying monsters and killer robots after a day of programming.

Table of contents