Footnotes
Chapter 10
briefly discusses bit fields.
Chapter 13
Technically speaking, its defined in the file NSObjCRuntime.h
, which is imported from inside the file Foundation.h
Note the use of the strings "A string to be copied."
and "So is this."
in the program. These are not string objects, but C-style character strings, as distinguished by the fact that an @
character does not precede the string. The two types are not interchangeable. If a function expects an array of char as an argument, you may pass it either an array of type char
or a literal C-style character string, but not a character string object.
Chapter 15
Currently, unichar
characters occupy 16 bits, but the Unicode standard provides for characters larger than that size. So in the future, unichar
characters might be larger than 16 bits. The bottom line is to never make an assumption about the size of a Unicode character.
Mac OS X and iOS provide an entire Address Book framework that offers extremely powerful capabilities for working with address books.
You also might want an initWithName:andEmail:
initialization method, but we dont show that here.
A method called sortUsingFunction:context:
lets you use a function instead of a method to perform the comparison.
A more general method could invoke each objects description
method for displaying each member of the set. That would allow sets containing any types of objects to be displayed in a readable format. Also note that you can display the contents of any collection with a single call to NSLog
, using the print object format characters "%@"
.
Developers Library
ESSENTIAL REFERENCES FOR PROGRAMMING PROFESSIONALS
Developers Library books are designed to provide practicing programmers with unique, high-quality references and tutorials on the programming languages and technologies they use in their daily work.
All books in the Developers Library are written by expert technology practitioners who are especially skilled at organizing and presenting information in a way thats useful for other programmers.
Key titles include some of the best, most widely acclaimed books within their topic areas:
PHP & MySQL Web Development
Luke Welling & Laura Thomson
ISBN 978-0-672-32916-6
MySQL
Paul DuBois
ISBN-13: 978-0-672-32938-8
Linux Kernel Development
Robert Love
ISBN-13: 978-0-672-32946-3
Python Essential Reference
David Beazley
ISBN-13: 978-0-672-32978-4
PostgreSQL
Korry Douglas
ISBN-13: 978-0-672-32756-2
C ++ Primer Plus
Stephen Prata
ISBN-13: 978-0321-77640-2
Developers Library books are available in print and in electronic formats at most retail and online bookstores, as well as by subscription from Safari Books Online at safari.informit.com
Developers Library
Programming in Objective-C, Third Edition
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, Third Edition
Copyright 2011 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 information contained herein.
ISBN-13: 978-0-321-71139-7
ISBN-10: 0-321-71139-4
Acquisitions Editor
Mark Taber
Development Editor
Michael Thurston
Managing Editor
Sandra Schroeder
Project Editor
Mandie Frank
Indexer
Larry Sweazy
Proofreader
Kathy Ruiz
Technical Editor
Michael Trent
Publishing Coordinator
Vanessa Evans
Designer
Gary Adair
Compositor
Mark Shirar
Library of Congress Cataloging-in-Publication Data:
Kochan, Stephen G.
Programming in objective-C / Stephen G. Kochan. -- 3rd ed.
p. cm.
Includes index.
ISBN 978-0-321-71139-7 (pbk.)
1. Objective-C (Computer program language) 2. Object-oriented
programming (Computer science) 3. Macintosh (Computer)--Programming.
I. Title.
QA76.64.K655 2011
005.117--dc23
2011015714
Printed in the United States of America
First Printing, June 2011
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Pearson cannot attest to the accuracy of this information. 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
For sales outside of the U.S., please contact
International Sales
To Roy and Ve, two people whom I dearly miss
Contents at a Glance
About the Author
Stephen Kochan is the author and coauthor of several bestselling titles on the C language, including Programming in C (Sams, 2004), Programming in ANSI C (Sams, 1994), and Topics in C Programming (Wiley, 1991), and several Unix titles, including Exploring the Unix System (Sams, 1992) and Unix Shell Programming (Sams, 2003). He has been programming on Macintosh computers since the introduction of the first Mac in 1984, and he wrote Programming C for the Mac as part of the Apple Press Library. In 2003 Kochan wrote Programming in Objective-C (Sams, 2003), and followed that with another Mac-related title, Beginning AppleScript (Wiley, 2004).
About the Technical Reviewer
Wendy Mui is a programmer and software development manager in the San Francisco Bay Area. After learning Objective-C from the second edition of Steve Kochans book, she landed a job at Bump Technologies, where she put her programming skills to good use working on the client app and the API/SDK for Bumps third party developers. Prior to her iOS experience, Wendy spent her formative years at Sun and various other tech companies in Silicon Valley and San Francisco. She got hooked on programming while earning a B.A. in Mathematics from University of California Berkeley. When not working, Wendy is pursuing her 4th Dan Tae Kwon Do black belt.