Full Download Programming in Objective C 2 0 2nd Edition Stephen G. Kochan PDF DOCX
Full Download Programming in Objective C 2 0 2nd Edition Stephen G. Kochan PDF DOCX
com
https://ebookname.com/product/programming-in-
objective-c-2-0-2nd-edition-stephen-g-kochan/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/programming-in-c-4th-edition-stephen-g-
kochan/
ebookname.com
https://ebookname.com/product/beginning-applescript-1st-edition-
stephen-g-kochan/
ebookname.com
https://ebookname.com/product/clr-via-c-applied-microsoft-net-
framework-2-0-programming-2nd-ed-edition-jeffrey-richter/
ebookname.com
https://ebookname.com/product/problems-of-rationality-1st-edition-
donald-davidson/
ebookname.com
Key Concepts of Romanian History Alternative Approaches to
Socio Political Languages 1st Edition Victor Neumann
https://ebookname.com/product/key-concepts-of-romanian-history-
alternative-approaches-to-socio-political-languages-1st-edition-
victor-neumann/
ebookname.com
https://ebookname.com/product/small-firms-in-tourism-international-
perspectives-advances-in-tourism-research-1st-edition-rhodri-thomas/
ebookname.com
https://ebookname.com/product/customer-service-training-101-quick-and-
easy-techniques-that-get-great-results-second-edition-renee-evenson/
ebookname.com
https://ebookname.com/product/the-battle-of-gettysburg-1863-3-the-
third-day-1st-edition-timothy-j-orr/
ebookname.com
https://ebookname.com/product/citizen-participation-at-the-local-
level-in-china-and-canada-1st-edition-andrew-sancton/
ebookname.com
Extreme Right In France Shields
https://ebookname.com/product/extreme-right-in-france-shields/
ebookname.com
Programming in
Objective-C 2.0
Stephen G. Kochan
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or Development
Editor
transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise,
without written permission from the publisher. No patent liability is assumed with respect to Michael Thurston
the use of the information contained herein. Although every precaution has been taken in Managing Editor
the preparation of this book, the publisher and author assume no responsibility for errors or Patrick Kanouse
omissions. Nor is any liability assumed for damages resulting from the use of the informa-
Project Editor
tion contained herein.
Mandie Frank
ISBN-13: 978-0-321-56615-7 Copy Editor
ISBN-10: 0-321-56615-7 Krista Hansing
Editorial Services,
Library of Congress Cataloging-in-Publication Data: Inc.
Kochan, Stephen G.
Programming in Objective-C 2.0 / Stephen G. Kochan. -- 2nd ed. Indexer
p. cm. Ken Johnson
ISBN 978-0-321-56615-7 (pbk.) Proofreader
1. Objective-C (Computer program language) 2. Object-oriented Arle Writing
programming (Computer science) 3. Macintosh (Computer)--Programming. and Editing
I. Title. Technical Editor
QA76.73.O115K63 2009 Michael Trent
005.1'17--dc22
2008049771 Publishing
Coordinator
Vanessa Evans
Printed in the United States of America
Designer
First Printing December 2008 Gary Adair
Compositor
Trademarks
Mark Shirar
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.
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
[email protected]
For sales outside of the U.S., please contact
International Sales
[email protected]
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!................................................................................................................................................................ 312
Miscellaneous Language Features........................................................................................................................................... 312
How Things Work.................................................................................................................................................................... 317
Exercises.................................................................................................................................................................................. 319
Part II: The Foundation Framework........................................................ 322
Chapter 14. Introduction to the Foundation Framework.......................................................................................................... 324
Foundation Documentation.................................................................................................................................................... 324
Chapter 15. Numbers, Strings, and Collections.......................................................................................................................... 328
Number Objects....................................................................................................................................................................... 329
String Objects.......................................................................................................................................................................... 333
Array Objects........................................................................................................................................................................... 348
Synthesized AddressCard Methods........................................................................................................................................ 356
Dictionary Objects................................................................................................................................................................... 374
Set Objects............................................................................................................................................................................... 377
Exercises.................................................................................................................................................................................. 382
Chapter 16. Working with Files.................................................................................................................................................. 384
Managing Files and Directories: NSFileManager.................................................................................................................. 385
Working with Paths: NSPathUtilities.h.................................................................................................................................. 396
Basic File Operations: NSFileHandle..................................................................................................................................... 404
Exercises.................................................................................................................................................................................. 409
Chapter 17. Memory Management.............................................................................................................................................. 412
The Autorelease Pool............................................................................................................................................................... 412
Reference Counting................................................................................................................................................................. 413
An Autorelease Example......................................................................................................................................................... 425
Summary of Memory-Management Rules............................................................................................................................. 426
Garbage Collection.................................................................................................................................................................. 427
Exercises.................................................................................................................................................................................. 429
Chapter 18. Copying Objects...................................................................................................................................................... 430
The copy and mutableCopy Methods...................................................................................................................................... 431
Shallow Versus Deep Copying................................................................................................................................................. 433
Implementing the <NSCopying> Protocol............................................................................................................................. 436
Copying Objects in Setter and Getter Methods...................................................................................................................... 439
Exercises.................................................................................................................................................................................. 441
Chapter 19. Archiving................................................................................................................................................................. 442
Archiving with XML Property Lists........................................................................................................................................ 442
Archiving with NSKeyedArchiver........................................................................................................................................... 444
Writing Encoding and Decoding Methods............................................................................................................................. 447
Using NSData to Create Custom Archives.............................................................................................................................. 454
Using the Archiver to Copy Objects........................................................................................................................................ 457
Exercises.................................................................................................................................................................................. 459
Part III: Cocoa and the iPhone SDK........................................................ 460
Chapter 20. Introduction to Cocoa............................................................................................................................................. 462
Framework Layers................................................................................................................................................................... 462
Cocoa Touch............................................................................................................................................................................ 463
Chapter 21. Writing iPhone Applications................................................................................................................................... 466
The iPhone SDK...................................................................................................................................................................... 466
Your First iPhone Application................................................................................................................................................ 466
An iPhone Fraction Calculator................................................................................................................................................ 483
Summary................................................................................................................................................................................. 498
Exercises.................................................................................................................................................................................. 499
Part IV: Appendixes................................................................................ 502
Glossary....................................................................................................................................................................................... 504
Appendix B. Objective-C 2.0 Language Summary...................................................................................................................... 512
Digraphs and Identifiers.......................................................................................................................................................... 512
Comments................................................................................................................................................................................ 516
Constants.................................................................................................................................................................................. 517
Data Types and Declarations.................................................................................................................................................. 520
Expressions.............................................................................................................................................................................. 531
Storage Classes and Scope...................................................................................................................................................... 546
Functions................................................................................................................................................................................. 550
Classes...................................................................................................................................................................................... 553
Statements............................................................................................................................................................................... 563
Exception Handling................................................................................................................................................................ 568
Preprocessor............................................................................................................................................................................ 568
Appendix C. Address Book Source Code.................................................................................................................................... 576
AddressCard Interface File...................................................................................................................................................... 576
AddressBook Interface File..................................................................................................................................................... 577
AddressCard Implementation File.......................................................................................................................................... 577
AddressBook Implementation File......................................................................................................................................... 579
Appendix D. Resources............................................................................................................................................................... 582
Answers to Exercises, Errata, and Such................................................................................................................................. 582
Objective-C Language............................................................................................................................................................. 582
C Programming Language....................................................................................................................................................... 583
Cocoa....................................................................................................................................................................................... 583
iPhone and iTouch Application Development........................................................................................................................ 584
❖
To Roy and Ve, two people whom I dearly miss
❖
Developer’s Library
ESSENTIAL REFERENCES FOR PROGRAMMING PROFESSIONALS
Key titles include some of the best, most widely acclaimed books within their
topic areas:
PHP & MySQL Web Development Python Essential Reference
Luke Welling & Laura Thomson David Beazley
ISBN 978-0-672-32916-6 ISBN-13: 978-0-672-32862-6
MySQL Programming in Objective-C
Paul DuBois Stephen G. Kochan
ISBN-13: 978-0-672-32938-8 ISBN-13: 978-0-321-56615-7
Linux Kernel Development PostgreSQL
Robert Love Korry Douglas
ISBN-13: 978-0-672-32946-3 ISBN-13: 978-0-672-33015-5
Developer’s Library books are available at most retail and online bookstores, as well
as by subscription from Safari Books Online at safari.informit.com
Developer’s
Library
informit.com/devlibrary
About the Author
Stephen Kochan is the author and coauthor of several bestselling titles on the C lan-
guage, 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 pro-
gramming 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).
Reader Services
Visit our website and register this book at www.informit.com/title/9780321566157 for
convenient access to any updates, downloads, or errata that might be available for this
book.
1
Introduction
When the iPhone was released in 2007, developers clamored for the opportunity to
develop applications for this revolutionary device.At first,Apple did not welcome third-
party application development.The company’s way of placating wannabe iPhone devel-
opers was to allow them to develop web-based applications.A web-based application runs
under the iPhone’s built-in Safari web browser and requires the user to connect to the
website that hosts the application in order to run it. Developers were not satisfied with
the many inherent limitations of web-based applications, and Apple shortly thereafter an-
nounced that developers would be able to develop so-called native applications for the
iPhone.
A native application is one that resides on the iPhone and runs under the iPhone’s op-
erating system, in the same way that the iPhone’s built-in applications (such as Contacts,
iPod, and Weather) run on the device.The iPhone’s OS is actually a version of Mac OS
X, which meant that applications could be developed and debugged on a MacBook Pro,
for example. In fact,Apple soon provided a powerful Software Development Kit (SDK)
that allowed for rapid iPhone application development and debugging.The availability of
an iPhone simulator made it possible for developers to debug their applications directly
on their development system, obviating the need to download and test the program on an
actual iPhone or iPod Touch device.
Chapter 4,“Data Types and Expressions,” describes the basic Objective-C data types
and how to use them in your programs.
Chapter 5,“Program Looping,” introduces the three looping statements you can use in
your programs: for, while, and do.
Making decisions is fundamental to any computer programming language. Chapter 6,
“Making Decisions,” covers the Objective-C language’s if and switch statements in detail.
Chapter 7,“More on Classes,” delves more deeply into working with classes and ob-
jects. Details about methods, multiple arguments to methods, and local variables are dis-
cussed here.
Chapter 8,“Inheritance,” introduces the key concept of inheritance.This feature makes
the development of programs easier because you can take advantage of what comes from
above. Inheritance and the notion of subclasses make modifying and extending existing
class definitions easy.
Chapter 9 discusses three fundamental characteristics of the Objective-C language.
Polymorphism, dynamic typing, and dynamic binding are the key concepts covered here.
Chapters 10–13 round out the discussion of the Objective-C language, covering issues
such as initialization of objects, protocols, categories, the preprocessor, and some of the
underlying C features, including functions, arrays, structures, and pointers.These underly-
ing features are often unnecessary (and often best avoided) when first developing object-
oriented applications. It’s recommended that you skim Chapter 13,“Underlying C
Features,” the first time through the text and return to it only as necessary to learn more
about a particular feature of the language.
Part II begins with Chapter 14,“Introduction to the Foundation Framework,” which
gives an introduction to the Foundation framework and how to access its documentation.
Chapters 15–19 cover important features of the Foundation framework.These include
number and string objects, collections, the file system, memory management, and the
process of copying and archiving objects.
By the time you’re done with Part II, you will be able to develop fairly sophisticated
programs in Objective-C that work with the Foundation framework.
Part III starts with Chapter 20,“Introduction to Cocoa.” Here you’ll get a quick
overview of the Application Kit that provides the classes you need to develop sophisti-
cated graphical applications on the Mac.
Chapter 21,“Writing iPhone Applications,” introduces the iPhone SDK and the UIKit
framework.This chapter illustrates a step-by-step approach to writing a simple iPhone (or
iTouch) application, followed by a calculator application that enables you to use your
iPhone to perform simple arithmetic calculations with fractions.
Because object-oriented parlance involves a fair amount of terminology,Appendix A,
“Glossary,” provides definitions of some common terms.
Appendix B,“Objective-C Language Summary,” gives a summary of the Objective-C
language, for your quick reference.
Appendix C,“Address Book Source Code,” gives the source code listing for two classes
that are developed and used extensively in Part II of this text.These classes define address
Acknowledgments 5
card and address book classes. Methods enable you to perform simple operations such as
adding and removing address cards from the address book, looking up someone, listing
the contents of the address book, and so on.
After you’ve learned how to write Objective-C programs, you can go in several direc-
tions.You might want to lean more about the underlying C programming language—or
you might want to start writing Cocoa programs to run on Mac OS X, or develop more
sophisticated iPhone applications. In any case,Appendix D,“Resources,” will guide you in
the right direction.
Acknowledgments
I would like to acknowledge several people for their help in the preparation of the first
edition of this text. First, I want to thank Tony Iannino and Steven Levy for reviewing the
manuscript. I am also grateful to Mike Gaines for providing his input.
I’d also like to thank my technical editors, Jack Purdum (first edition) and Mike Trent.
I was lucky enough to have Mike review both editions of this text. He provided the most
thorough review of any book I’ve ever written. Not only did he point out weaknesses,
but he was also generous enough to offer his suggestions. Because of Mike’s comments in
the first edition, I changed my approach to teaching memory management and tried to
make sure that every program example in this book was “leak free.” Mike also provided
invaluable input for my chapter on iPhone programming.
From the first edition, Catherine Babin supplied the cover photograph and provided
me with many wonderful pictures to choose from. Having the cover art from a friend
made the book even more special.
I am so grateful to Mark Taber from Pearson for putting up with all delays and for be-
ing kind enough to work around my schedule and to tolerate my consistent missing of
deadlines while working on this second edition. From Pearson I’d also like to thank my
development editor, Michael Thurston, my copy editor, Krista Hansing, and my project
editor, Mandie Frank, who expertly managed the mad dash to the finish line.
As always, my children showed an incredible amount of maturity and patience while I
pulled this book together over the summer (and then into the fall)! To Gregory, Linda,
and Julia, I love you!
Stephen G. Kochan
October 2008
Part I
The Objective-C 2.0
Language
1 Introduction
2 Programming in Objective-C
3 Classes, Objects, and Methods
4 Data Types and Expressions
5 Program Looping
6 Making Decisions
7 More on Classes
8 Inheritance
9 Polymorphism, Dynamic Typing,
and Dynamic Binding
10 More on Variables and Data Types
11 Categories and Protocols
12 The Preprocessor
13 Underlying C Language Features
2
Programming in
Objective-C
Igram.You
n this chapter, we dive right in and show you how to write your first Objective-C pro-
won’t work with objects just yet; that’s the topic of the next chapter.We want you
to understand the steps involved in keying in a program and compiling and running it.We
give special attention to this process both under Windows and on a Macintosh computer.
To begin, let’s pick a rather simple example: a program that displays the phrase “Pro-
gramming is fun!” on your screen.Without further ado, Program 2.1 shows an Objective-
C program to accomplish this task:
Program 2.1
// First program example
#import Foundation/Foundation.h>
[pool drain];
return 0;
}
Note
These tools should be preinstalled on all Macs that came with OS X. If you separately in-
stalled OS X, make sure you install the Developer Tools as well.
Using Xcode
Xcode is a sophisticated application that enables you to easily type in, compile, debug, and
execute programs. If you plan on doing serious application development on the Mac,
learning how to use this powerful tool is worthwhile.We just get you started here. Later
we return to Xcode and take you through the steps involved in developing a graphical ap-
plication with it.
First, Xcode is located in the Developer folder inside a subfolder called Applications.
Figure 2.1 shows its icon.
Start Xcode. Under the File menu, select New Project (see Figure 2.2).
Scroll down the left pane until you get to Command Line Utility. In the upper-right
pane, highlight Foundation Tool.Your window should now appear as shown in Figure 2.4.
We’ll call the first program prog1, so type that into the Save As field.You may want to
create a separate folder to store all your projects in. On my system, I keep the projects for
this book in a folder called ObjC Progs.
Click the Save button to create your new project.This gives you a project window
such as the one shown in Figure 2.6. Note that your window might display differently if
you’ve used Xcode before or have changed any of its options.
Now it’s time to type in your first program. Select the file prog1.m in the upper-right
pane.Your Xcode window should now appear as shown in Figure 2.7.
Objective-C source files use .m as the last two characters of the filename (known as its
extension).Table 2.1 lists other commonly used filename extensions.
Returning to your Xcode project window, the bottom-right side of the window shows
the file called prog1.m and contains the following lines:
#import <Foundation/Foundation.h>
Note
If you can’t see the file’s contents displayed, you might have to click and drag up the bottom-
right pane to get the edit window to appear. Again, this might be the case if you’ve previously
used Xcode.
You can edit your file inside this window. Xcode has created a template file for you to
use.
Make changes to the program shown in the Edit window to match Program 2.1.The
line you add at the beginning of prog1.m that starts with two slash characters (//) is called
a comment; we talk more about comments shortly.
Your program in the edit window should now look like this:
// First program example
[pool drain];
return 0;
}
Don’t worry about all the colors shown for your text onscreen. Xcode indicates values,
reserved words, and so on with different colors.
Now it’s time to compile and run your first program—in Xcode terminology, it’s called
build and run.You need to save your program first, however, by selecting Save from the File
menu. If you try to compile and run your program without first saving your file, Xcode
asks whether you want to save it.
Compiling and Running Programs 15
Under the Build menu, you can select either Build or Build and Run. Select the latter
because that automatically runs the program if it builds without any errors.You can also
click the Build and Go icon that appears in the toolbar.
Note
Build and Go means “Build and then do the last thing I asked you to do,” which might be
Run, Debug, Run with Shark or Instruments, and so on. The first time you use this for a proj-
ect, Build and Go means to build and run the program, so you should be fine using this op-
tion. However, just be aware of the distinction between “Build and Go” and “Build and Run.”
If you made mistakes in your program, you’ll see error messages listed during this step.
In this case, go back, fix the errors, and repeat the process.After all the errors have been
removed from the program, a new window appears, labeled prog1 – Debugger Console.
This window contains the output from your program and should look similar to Figure
2.8. If this window doesn’t automatically appear, go to the main menu bar and select Con-
sole from the Run menu.We discuss the actual contents of the Console window shortly.
You’re now done with the procedural part of compiling and running your first pro-
gram with Xcode (whew!).The following summarizes the steps involved in creating a
new program with Xcode:
1. Start the Xcode application.
2. If this is a new project, select File, New Project.
3. For the type of application, select Command Line Utility, Foundation Tool, and
click Choose.
Discovering Diverse Content Through
Random Scribd Documents
— Tante, on s’habille comme ça ici ? vais-je me promener ainsi à
moitié nu ? toi, tu mets cependant des bas…
— Oh, mais ! je les ôterai à la plage. Tu verras, nous allons
patauger dans la mer.
Je le chargeai d’une bêche et d’un seau, dans lequel je mis un
essuie-mains. Je voulus qu’il vît la mer tout d’un coup dans toute sa
grandeur. Pour cela nous grimpâmes par derrière une haute dune.
— Voilà ! fis-je, au sommet.
Il resta muet, respirant par saccades, puis :
— Ça ça ça, tante, c’est c’est c’est de l’eau… elle est bleue, elle
est verte, et et encore autre chose.
— Mauve et violette, ajoutai-je. Maintenant descendons.
— Non, tante, non, on ne peut pas marcher là-dessus, elle
viendra sur nous, elle avance.
— Elle recule aussi, regarde.
— Ah ! oui ! pourquoi ?
— Je te raconterai cela plus tard. Viens, nous irons sur le sable,
puis, là entre ces pilots, nous chercherons des moules.
Nous descendîmes. Il était devenu précautionneux, dans la
crainte que l’eau nous entraînerait.
Bientôt il jubilait en une joie délirante… le sable chaud, les
coquillages… Entre les brise-lames, nous cherchâmes, sous les
pierres, des moules dont nous remplissions le seau. Subitement il se
redressa en criant et se mit sur la défensive, le dos contre un pilot,
et une jambe levée comme pour donner un coup de pied.
— Tante ! Tante !
C’était un grand crabe qui, les ciseaux ouverts, s’avançait vers lui
en sa marche latérale.
Je pris la bête et la déposai dans le seau.
— Tante, jette-la… Tante, est-ce une de ces bêtes sorties de la
mer et qui sont devenues des hommes ?
J’avais envie de dire « oui »…
— Petite cruche, il ne faut pas avoir si peur. Cette bête n’est pas
méchante, mais elle se défend, tu comprends… Nous allons la faire
bouillir et la manger pour notre souper.
— Mais, tante, c’est infâme, fit-il, en français.
— Que dis-tu ? tu répètes les paroles de ton oncle.
Ce petit bougre a tout le temps raison, pensais-je.
— Viens, je vais te tremper dans l’eau.
J’ôtai mes bas et ma jupe ; je le mis nu. Nous marchions à petits
pas dans la mer. Il avait confiance maintenant, il riait aux éclats,
quand l’écume nous sautait au visage. Il bégayait de joie et
d’émotion, et sa peau était si fine, ses cheveux si blonds, son regard
si radieusement bleu, qu’il faisait corps avec le sable doré, l’eau
argentée et l’atmosphère embuée d’un poudroiement de nacre. Il
incarnait en ce moment la joie de vivre.
… Le bonheur m’est interdit dans ce monde, j’ai devant moi les
éléments de la joie et de la beauté les plus pures, et ils ne me sont
que des éléments de torture. Je dois assister à cet épanouissement
d’une âme adorable, et dans trois mois… et je ne peux rien, rien.
Lui ne comprenait pas pourquoi, tout d’un coup, ma figure se
contractait.
— Mais, tante, on dirait que tu es fâchée, je n’ai pas été
méchant.
— Mon chéri à moi, tu es tout amour, mais j’ai mal à mon cœur.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com