Objective-C Memory Management Essentials
eBook - ePub

Objective-C Memory Management Essentials

Gibson Tang, Maxim Vasilkov

Buch teilen
  1. 200 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Objective-C Memory Management Essentials

Gibson Tang, Maxim Vasilkov

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

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.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Objective-C Memory Management Essentials als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Objective-C Memory Management Essentials von Gibson Tang, Maxim Vasilkov im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
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.

Inhaltsverzeichnis