logo资料库

Effective Objective-C 2.0.pdf完整版

第1页 / 共311页
第2页 / 共311页
第3页 / 共311页
第4页 / 共311页
第5页 / 共311页
第6页 / 共311页
第7页 / 共311页
第8页 / 共311页
资料共311页,剩余部分请下载后查看
Preface
Acknowledgments
About the Author
Chapter 1: Accustoming Yourself to Objective-C
Item 1: Familiarize Yourself with Objective-C’s Roots
Item 2: Minimize Importing Headers in Headers
Item 3: Prefer Literal Syntax over the Equivalent Methods
Item 4: Prefer Typed Constants to Preprocessor #define
Item 5: Use Enumerations for States, Options, and Status Codes
Chapter 2: Objects, Messaging, and the Runtime
Item 6: Understand Properties
Item 7: Access Instance Variables Primarily Directly When Accessing Them Internally
Item 8: Understand Object Equality
Item 9: Use the Class Cluster Pattern to Hide Implementation Detail
Item 10: Use Associated Objects to Attach Custom Data to Existing Classes
Item 11: Understand the Role of objc_msgSend
Item 12: Understand Message Forwarding
Item 13: Consider Method Swizzling to Debug Opaque Methods
Item 14: Understand What a Class Object Is
Chapter 3: Interface and API Design
Item 15: Use Prefix Names to Avoid Namespace Clashes
Item 16: Have a Designated Initializer
Item 17: Implement the description Method
Item 18: Prefer Immutable Objects
Item 19: Use Clear and Consistent Naming
Item 20: Prefix Private Method Names
Item 21: Understand the Objective-C Error Model
Item 22: Understand the NSCopying Protocol
Chapter 4: Protocols and Categories
Item 23: Use Delegate and Data Source Protocols for Interobject Communication
Item 24: Use Categories to Break Class Implementations into Manageable Segments
Item 25: Always Prefix Category Names on Third-Party Classes
Item 26: Avoid Properties in Categories
Item 27: Use the Class-Continuation Category to Hide Implementation Detail
Item 28: Use a Protocol to Provide Anonymous Objects
Chapter 5: Memory Management
Item 29: Understand Reference Counting
Item 30: Use ARC to Make Reference Counting Easier
Item 31: Release References and Clean Up Observation State Only in dealloc
Item 32: Beware of Memory Management with Exception-Safe Code
Item 33: Use Weak References to Avoid Retain Cycles
Item 34: Use Autorelease Pool Blocks to Reduce High-Memory Waterline
Item 35: Use Zombies to Help Debug Memory-Management Problems
Item 36: Avoid Using retainCount
Chapter 6: Blocks and Grand Central Dispatch
Item 37: Understand Blocks
Item 38: Create typedefs for Common Block Types
Item 39: Use Handler Blocks to Reduce Code Separation
Item 40: Avoid Retain Cycles Introduced by Blocks Referencing the Object Owning Them
Item 41: Prefer Dispatch Queues to Locks for Synchronization
About This eBook ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site. Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “ ” link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Effective Objective-C 2.0 52 Specific Ways to Improve Your iOS and OS X Programs Matt Galloway Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact: International Sales international@pearsoned.com Visit us on the Web: informit.com/aw The Cataloging-in-Publication Data is on file with the Library of Congress. Copyright © 2013 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290. ISBN-13: 978-0-321-91701-0 ISBN-10: 0-321-91701-4 Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana. First printing, May 2013 Editor-in-Chief
Mark Taub Acquisitions Editor Trina MacDonald Development Editor Chris Zahn Managing Editor John Fuller Project Editor Elizabeth Ryan Packager Vicki Rowland Copy Editor Evelyn W. Pyle Indexer Sharon Hilgenberg Proofreader Archie Brodsky Technical Reviewers Anthony Herron Cesare Rocchi Chris Wagner Editorial Assistant Olivia Bassegio Cover Designer Chuti Prasertsith Compositor Vicki Rowland
To Rosie
Contents Preface Acknowledgments About the Author Chapter 1: Accustoming Yourself to Objective-C Item 1: Familiarize Yourself with Objective-C’s Roots Item 2: Minimize Importing Headers in Headers Item 3: Prefer Literal Syntax over the Equivalent Methods Item 4: Prefer Typed Constants to Preprocessor #define Item 5: Use Enumerations for States, Options, and Status Codes Chapter 2: Objects, Messaging, and the Runtime Item 6: Understand Properties Item 7: Access Instance Variables Primarily Directly When Accessing Them Internally Item 8: Understand Object Equality Item 9: Use the Class Cluster Pattern to Hide Implementation Detail Item 10: Use Associated Objects to Attach Custom Data to Existing Classes Item 11: Understand the Role of objc_msgSend Item 12: Understand Message Forwarding Item 13: Consider Method Swizzling to Debug Opaque Methods Item 14: Understand What a Class Object Is Chapter 3: Interface and API Design Item 15: Use Prefix Names to Avoid Namespace Clashes Item 16: Have a Designated Initializer Item 17: Implement the description Method Item 18: Prefer Immutable Objects Item 19: Use Clear and Consistent Naming Item 20: Prefix Private Method Names Item 21: Understand the Objective-C Error Model Item 22: Understand the NSCopying Protocol
分享到:
收藏