programming_cocoa_with_ruby.pdf

(9064 KB) Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
821544834.043.png
Download at Boykma.Com
What Readers Are Saying About
Programming Cocoa with Ruby
This isn’t just a book on RubyCocoa; it is probably the best book I’ve
seen that explains Cocoa technology. It actually explains how some of
the core technologies, especially bindings, work instead of just show-
ing an example of how to use them.
Allison Newman
Cocoa application developer
Learning a new API is hard enough, but learning a new API and a new
programming language at the same time can be overwhelming. Pro-
gramming Cocoa with Ruby is written for those of us used to a lan-
guage like Ruby or Python who want to learn about all the great stuff
Cocoa has to offer.
Jeremy McAnally
Developer, entp
The influence of Smalltalk on Ruby and Objective-C is considerable.
It shouldn’t be a surprise then that Cocoa, whose native tongue is
Objective-C, can be effectively learned and programmed from Ruby
in a way that captures the succinctness and expressiveness of this
newly popular scripting language. Brian’s book is a great introduc-
tion to the agile development of Cocoa apps, it serves as a primer on
Cocoa, and it demonstrates sound and thoughtful development prac-
tices and hygiene throughout.
Jerry Kuch
Principal engineer, EMC Corporation
821544834.044.png 821544834.045.png 821544834.046.png
Download at Boykma.Com
Programming Cocoa with Ruby
Create Compelling Mac Apps Using RubyCocoa
Brian Marick
The Pragmatic Bookshelf
Raleigh, North Carolina
Dallas, Texas
 
Download at Boykma.Com
Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts are claimed as trademarks. Where those designations appear in this book, and The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
Copyright © 2009 Brian Marick.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmit-
ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN-10: 1-934356-19-0
ISBN-13: 978-1-934356-19-7
Printed on acid-free paper.
P1.0 printing, July 2009
Version: 2009-8-6
821544834.001.png 821544834.002.png 821544834.003.png 821544834.004.png 821544834.005.png 821544834.006.png 821544834.007.png 821544834.008.png 821544834.009.png 821544834.010.png 821544834.011.png 821544834.012.png 821544834.013.png 821544834.014.png 821544834.015.png 821544834.016.png 821544834.017.png 821544834.018.png 821544834.019.png 821544834.020.png 821544834.021.png 821544834.022.png 821544834.023.png 821544834.024.png 821544834.025.png 821544834.026.png 821544834.027.png 821544834.028.png 821544834.029.png 821544834.030.png 821544834.031.png 821544834.032.png 821544834.033.png 821544834.034.png 821544834.035.png 821544834.036.png 821544834.037.png 821544834.038.png 821544834.039.png 821544834.040.png 821544834.041.png 821544834.042.png
Download at Boykma.Com
Contents
1
Introduction
11
1.1
What Is Cocoa?
. . . . . . . . . . . . . . . . . . . . . . .
12
1.2
What Is RubyCocoa?
. . . . . . . . . . . . . . . . . . . .
12
1.3
12
1.4
RubyCocoa? That’s So Last Year! . . . . . . . . . . . . .
13
1.5
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . .
13
1.6
Versions
. . . . . . . . . . . . . . . . . . . . . . . . . . .
15
1.7
Our Example App . . . . . . . . . . . . . . . . . . . . . .
16
1.8
18
1.9
Some Terminology
. . . . . . . . . . . . . . . . . . . . .
19
1.10
Service After the Sale . . . . . . . . . . . . . . . . . . . .
19
1.11
Solving Problems
. . . . . . . . . . . . . . . . . . . . . .
19
1.12
Acknowledgments . . . . . . . . . . . . . . . . . . . . . .
20
2
How Do We Get This Thing Started?
22
2.1
A Program That Prints
. . . . . . . . . . . . . . . . . . .
23
2.2
Putting an Item in the Status Bar
. . . . . . . . . . . .
26
2.3
Menus
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
2.4
An Application Bundle
. . . . . . . . . . . . . . . . . . .
31
2.5
What Now? . . . . . . . . . . . . . . . . . . . . . . . . . .
35
I
A First Realistic App
36
3
Working with Interface Builder and Xcode
37
3.1
The Basics . . . . . . . . . . . . . . . . . . . . . . . . . .
38
3.2
48
3.3
Debugging
. . . . . . . . . . . . . . . . . . . . . . . . . .
55
3.4
57
3.5
Attributes
. . . . . . . . . . . . . . . . . . . . . . . . . .
58
3.6
60
 
Zgłoś jeśli naruszono regulamin