Objc.pdf

Disponível somente no TrabalhosFeitos
  • Páginas : 173 (43221 palavras )
  • Download(s) : 0
  • Publicado : 10 de outubro de 2012
Ler documento completo
Amostra do texto
The Objective-C Programming Language
Tools & Languages: Objective-C
2010-07-13
Apple Inc.
. 2010 Apple Inc.
All rights reserved.
No part of this publication may be reproduced,
stored in a retrieval system, or transmitted, in
any form or by any means, mechanical,
electronic, photocopying, recording, or
otherwise, without prior written permission of
Apple Inc., with the followingexceptions: Any
person is hereby authorized to store
documentation on a single computer for
personal use only and to print copies of
documentation for personal use provided that
the documentation contains Apple¡¯s copyright
notice.
The Apple logo is a trademark of Apple Inc.
Use of the ¡°keyboard¡± Apple logo
(Option-Shift-K) for commercial purposes
without the prior written consent of Applemay
constitute trademark infringement and unfair
competition in violation of federal and state
laws.
No licenses, express or implied, are granted
with respect to any of the technology described
in this document. Apple retains all intellectual
property rights associated with the technology
described in this document. This document is
intended to assist application developers to
developapplications only for Apple-labeled
computers.
Every effort has been made to ensure that the
information in this document is accurate. Apple
is not responsible for typographical errors.
Apple Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
.Mac is a registered service mark of Apple Inc.
Apple, the Apple logo, Bonjour, Cocoa,
Instruments, Mac, Mac OS, Objective-C, and
Xcode aretrademarks of Apple Inc., registered
in the United States and other countries.
Java is a registered trademark of Oracle and/or
its affiliates
IOS is a trademark or registered trademark of
Cisco in the U.S. and other countries and is used
under license.
Times is a registered trademark of Heidelberger
Druckmaschinen AG, available from Linotype
Library GmbH.
Simultaneously published in theUnited States
and Canada.
Even though Apple has reviewed this document,
APPLE MAKES NO WARRANTY OR REPRESENTATION,
EITHER EXPRESS OR IMPLIED, WITH RESPECT TO
THIS DOCUMENT, ITS QUALITY, ACCURACY,
MERCHANTABILITY, OR FITNESS FOR A PARTICULAR
PURPOSE. AS A RESULT, THIS DOCUMENT IS
PROVIDED ¡°AS IS,¡± AND YOU, THE READER, ARE
ASSUMING THE ENTIRE RISK AS TO ITS QUALITY
AND ACCURACY.
IN NOEVENT WILL APPLE BE LIABLE FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES RESULTING FROM ANY
DEFECT OR INACCURACY IN THIS DOCUMENT, even
if advised of the possibility of such damages.
THE WARRANTY AND REMEDIES SET FORTH ABOVE
ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL
OR WRITTEN, EXPRESS OR IMPLIED. No Apple
dealer, agent, or employee is authorized to make
anymodification, extension, or addition to this
warranty.
Some states do not allow the exclusion or limitation
of implied warranties or liability for incidental or
consequential damages, so the above limitation or
exclusion may not apply to you. This warranty gives
you specific legal rights, and you may also have
other rights which vary from state to state.
Contents
Introduction Introduction toThe Objective-C Programming Language 9
Who Should Read This Document 9
Organization of This Document 10
Conventions 10
See Also 11
Runtime 11
Memory Management 11
Chapter 1 Objects, Classes, and Messaging 13
Runtime 13
Objects 13
Object Basics 13
id 14
Dynamic Typing 14
Memory Management 15
Object Messaging 15
Message Syntax 15
Sending Messages to nil 17
The Receiver¡¯s InstanceVariables 17
Polymorphism 18
Dynamic Binding 18
Dynamic Method Resolution 19
Dot Syntax 19
Classes 23
Inheritance 23
Class Types 26
Class Objects 27
Class Names in Source Code 32
Testing Class Equality 33
Chapter 2 Defining a Class 35
Source Files 35
Class Interface 35
Importing the Interface 37
Referring to Other Classes 37
The Role of the Interface 38
Class Implementation 38...
tracking img