首页 > > > [iPhone开发书籍大全].Programming.in.Objective-C.2.0.2…

[iPhone开发书籍大全].Programming.in.Objective-C.2.0.2nd(Addison.Wesley.2009).pdf

[iPhone开发书籍大全].Programming.in.O…

上传者: stone 2011-06-10 评分1 评论0 下载43 收藏10 阅读量496 暂无简介 简介 举报

简介:本文档为《[iPhone开发书籍大全].Programming.in.Objective-C.2.0.2nd(Addison.Wesley.2009)pdf》,可适用于手机软件领域,主题内容包含ProgramminginObjectiveCStephenGKochanUpperSaddleRiver,NJ•Boston•Indianapol符等。

Programming in Objective-C 2.0 Stephen G. Kochan Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City Programming in Objective-C 2.0 Copyright 2009 by Pearson Education, Inc. All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the informa- tion contained herein. ISBN-13: 978-0-321-56615-7 ISBN-10: 0-321-56615-7 Library of Congress Cataloging-in-Publication Data: Kochan, Stephen G. Programming in Objective-C 2.0 / Stephen G. Kochan. -- 2nd ed. p. cm. ISBN 978-0-321-56615-7 (pbk.) 1. Objective-C (Computer program language) 2. Object-oriented programming (Computer science) 3. Macintosh (Computer)--Programming. I. Title. QA76.73.O115K63 2009 005.1'17--dc22 2008049771 Printed in the United States of America First Printing December 2008 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this infor- mation. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. Bulk Sales Pearson offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contact International Sales international@pearsoned.com Acquisitions Editor Mark Taber Development Editor Michael Thurston Managing Editor Patrick Kanouse Project Editor Mandie Frank Copy Editor Krista Hansing Editorial Services, Inc. Indexer Ken Johnson Proofreader Arle Writing and Editing Technical Editor Michael Trent Publishing Coordinator Vanessa Evans Designer Gary Adair Compositor Mark Shirar Table of Contents Copyright..................................................................................................... 1 Developer’s Library..................................................................................... 4 About the Author......................................................................................... 5 About the Technical Reviewers................................................................... 5 We Want to Hear from You!........................................................................ 6 Reader Services.......................................................................................... 6 Chapter 1. Introduction............................................................................... 8 What You Will Learn from This Book............................................................................................................................................ 9 How This Book Is Organized......................................................................................................................................................... 10 Acknowledgments......................................................................................................................................................................... 12 Part I: The Objective-C 2.0 Language......................................................... 14 Chapter 2. Programming in Objective-C....................................................................................................................................... 16 Compiling and Running Programs............................................................................................................................................ 16 Explanation of Your First Program........................................................................................................................................... 25 Displaying the Values of Variables............................................................................................................................................ 29 Summary................................................................................................................................................................................... 32 Exercises.................................................................................................................................................................................... 32 Chapter 3. Classes, Objects, and Methods.................................................................................................................................... 34 What Is an Object, Anyway?..................................................................................................................................................... 34 Instances and Methods............................................................................................................................................................. 35 An Objective-C Class for Working with Fractions.................................................................................................................... 37 The @interface Section............................................................................................................................................................. 40 The @implementation Section................................................................................................................................................. 44 The program Section................................................................................................................................................................. 45 Accessing Instance Variables and Data Encapsulation............................................................................................................. 51 Summary.................................................................................................................................................................................... 54 Exercises.................................................................................................................................................................................... 54 Chapter 4. Data Types and Expressions....................................................................................................................................... 56 Data Types and Constants......................................................................................................................................................... 56 Arithmetic Expressions............................................................................................................................................................. 63 Assignment Operators............................................................................................................................................................... 71 A Calculator Class...................................................................................................................................................................... 72 Bit Operators............................................................................................................................................................................. 74 Types: _Bool, _Complex, and _Imaginary.............................................................................................................................. 80 Exercises.................................................................................................................................................................................... 80 Chapter 5. Program Looping........................................................................................................................................................ 84 The for Statement...................................................................................................................................................................... 85 The while Statement.................................................................................................................................................................. 96 The do Statement..................................................................................................................................................................... 101 The break Statement............................................................................................................................................................... 102 The continue Statement.......................................................................................................................................................... 103 Summary.................................................................................................................................................................................. 103 Exercises.................................................................................................................................................................................. 103 Chapter 6. Making Decisions...................................................................................................................................................... 106 The if Statement...................................................................................................................................................................... 106 The switch Statement............................................................................................................................................................... 127 Boolean Variables.................................................................................................................................................................... 130 The Conditional Operator........................................................................................................................................................ 135 Exercises.................................................................................................................................................................................. 136 Chapter 7. More on Classes......................................................................................................................................................... 140 Separate Interface and Implementation Files........................................................................................................................ 140 Synthesized Accessor Methods................................................................................................................................................ 146 Accessing Properties Using the Dot Operator......................................................................................................................... 147 Multiple Arguments to Methods............................................................................................................................................. 148 Local Variables......................................................................................................................................................................... 153 The self Keyword...................................................................................................................................................................... 156 Allocating and Returning Objects from Methods................................................................................................................... 157 Exercises.................................................................................................................................................................................. 163 Chapter 8. Inheritance................................................................................................................................................................ 164 It All Begins at the Root........................................................................................................................................................... 164 Extension Through Inheritance: Adding New Methods......................................................................................................... 169 Overriding Methods................................................................................................................................................................. 182 Extension Through Inheritance: Adding New Instance Variables......................................................................................... 188 Abstract Classes....................................................................................................................................................................... 190 Exercises................................................................................................................................................................................... 191 Chapter 9. Polymorphism, Dynamic Typing, and Dynamic Binding......................................................................................... 194 Polymorphism: Same Name, Different Class.......................................................................................................................... 194 Dynamic Binding and the id Type........................................................................................................................................... 198 Compile Time Versus Runtime Checking............................................................................................................................... 200 The id Data Type and Static Typing........................................................................................................................................ 201 Asking Questions About Classes............................................................................................................................................. 202 Exception Handling Using @try............................................................................................................................................. 207 Exercises.................................................................................................................................................................................. 210 Chapter 10. More on Variables and Data Types......................................................................................................................... 212 Initializing Classes................................................................................................................................................................... 212 Scope Revisited........................................................................................................................................................................ 214 Storage Class Specifiers.......................................................................................................................................................... 220 Enumerated Data Types.......................................................................................................................................................... 222 The typedef Statement............................................................................................................................................................ 225 Data Type Conversions............................................................................................................................................................ 227 Exercises.................................................................................................................................................................................. 229 Chapter 11. Categories and Protocols......................................................................................................................................... 232 Categories................................................................................................................................................................................ 232 Protocols.................................................................................................................................................................................. 238 Composite Objects................................................................................................................................................................... 242 Exercises.................................................................................................................................................................................. 243 Chapter 12. The Preprocessor..................................................................................................................................................... 246 The #define Statement............................................................................................................................................................ 246 The #import Statement........................................................................................................................................................... 254 Conditional Compilation......................................................................................................................................................... 257 Exercises.................................................................................................................................................................................. 260 Chapter 13. Underlying C Language Features............................................................................................................................ 262 Arrays...................................................................................................................................................................................... 263 Functions................................................................................................................................................................................. 269 Structures................................................................................................................................................................................ 278 Pointers................................................................................................................................................................................... 290 Unions..................................................................................................................................................................................... 309 They’re Not Objects!...................................................................................................................

该用户的其他资料

  • 名称/格式
  • 评分
  • 下载次数
  • 资料大小
  • 上传时间

用户评论

0/200
    暂无评论
上传我的资料

相关资料

资料评价:

/ 589
所需积分:5 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!