Tài liệu MacRuby in Action pptx

270 862 0
  • Loading ...
1/270 trang
Tải xuống

Thông tin tài liệu

Ngày đăng: 17/02/2014, 15:20

MANNING Brendan G. LimWITH Jerry Cheung AND Jeremy McAnallyIN ACTIONwww.it-ebooks.infoMacRuby in Actionwww.it-ebooks.infowww.it-ebooks.infoMacRuby in ActionBRENDAN G. LIMWITH JERRY CHEUNGAND JEREMY MCANALLYMANNINGSHELTER ISLANDwww.it-ebooks.infoFor online information and ordering of this and other Manning books, please visitwww.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contactSpecial Sales DepartmentManning Publications Co.20 Baldwin RoadPO Box 261Shelter Island, NY 11964Email: orders@manning.com©2012 by Manning Publications Co. All rights reserved.No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without elemental chlorine.Development editor: Sara OnstineManning Publications Co. Technical proofreader: Nick Howard20 Baldwin Road Copyeditors: Lianna Wlasiuk, Tiffany TaylorPO Box 261 Proofreader: Melody DolabShelter Island, NY 11964 Typesetter: Marija TudorCover designer: Marija TudorISBN: 9781935182498Printed in the United States of America1 2 3 4 5 6 7 8 9 10 – MAL – 18 17 16 15 14 13 12www.it-ebooks.infovbrief contentsPART 1 STARTING WITH MACRUBY 11 ■Introducing MacRuby 32■Using Macirb and the Apple development tools 373■Going beyond the basics with Xcode Interface Builder 64PART 2 TAKE IT FOR A SPIN 854■Using the delegate pattern 875■Notifications and implementing the observer pattern 1046■Using key-value coding and key-value observing 1207■Implementing persistence with Core Data 1418■Core Animation basics 168PART 3 MACRUBY EXTRAS 1879■HotCocoa 18910■MacRuby testing 20311■MacRuby and the Mac App Store 216www.it-ebooks.infowww.it-ebooks.infoviicontentspreface xiiiacknowledgments xivabout this book xviabout the authors xixabout the cover illustration xxPART 1 STARTING WITH MACRUBY 11 Introducing MacRuby 31.1 Introducing MacRuby 4The MacRuby difference 4■Setting up your environment 5Hello World, part 1 61.2 Cocoa: What you need to know 7Important classes and concepts 8■How Cocoa implements common design patterns 101.3 Objective-C and Ruby: what you need to know 11A shared heritage 12■Objective-C 101 13Ruby 101 17www.it-ebooks.infoCONTENTSviii1.4 Diving into MacRuby 21Class structure 21■Creating MacRuby classes 23Syntax and method signatures 24■Using Ruby and Objective-C methods 26■Creating user interfaces 271.5 Hello World, part 2 28Creating an Xcode project 29■Creating the interface 30Creating the controller 32■Connecting the interface and controller 341.6 Summary 352 Using Macirb and the Apple development tools 372.1 Using external libraries with MacRuby 38Loading frameworks 38■Loading Objective-C libraries as bundles 39■Loading Ruby gems 412.2 Exploring Macirb 42Comparing the Ruby and MacRuby consoles 42Working in the MacRuby console 43■Macirb tips and tricks 432.3 Building a Pomodoro application in Xcode 47Creating a new MacRuby project 47■Constructing the interface 50■Creating the controller 53■Connecting the controller and the interface 56■Running the application 58Releasing the application 582.4 Summary 633 Going beyond the basics with Xcode Interface Builder 643.1 About Interface Builder 65History of Interface Builder 65■Getting around Interface Builder 653.2 Creating connections 69Understanding outlets 69■Understanding actions 713.3 Creating the Todo List application 73Constructing the user interface 73■Creating the model 79■Creating the controller 79■Connecting outlets and actions 82■Running and packaging the application 833.4 Summary 84www.it-ebooks.infoCONTENTSixPART 2 TAKE IT FOR A SPIN 854 Using the delegate pattern 874.1 What are delegates? 88How do delegate methods work? 88■Implementing the delegate pattern 894.2 Delegation as an extension technique 92Delegation the Cocoa way 93■Delegation using Forwardable 934.3 Using delegation in a custom MacRuby web browser 94Creating the browser interface 94■Setting up the controller 95■Implementing delegate methods in the controller 98■Connecting outlets and actions 100Taking MacRuby Browser for a spin 1024.4 Summary 1035 Notifications and implementing the observer pattern 1045.1 Notifying multiple objects 105When to use notifications 105■Managing notifications 1065.2 Setting up notifications 107Creating notifications 108■Posting notifications to the notification center 1085.3 Queuing notifications 109Using posting styles 109■Coalescing notifications 110Queuing multiple notifications 112■Removing notifications 1135.4 Responding to notifications 114Adding notification observers 114■Removing notification observers 1165.5 Building an iTunes-notification observer 116Creating the script 116■Running the script 1185.6 Summary 1186 Using key-value coding and key-value observing 1206.1 Simplifying code with key-value coding 121Accessing object properties with KVC 121■Handling unknown keys 123■Understanding key paths and collection operators 125www.it-ebooks.info[...]... HotCocoa Getting started 9.2 189 190 Built -in mappings 191 Applications and menus 191 More advanced layouts 198 9.3 Building a speech application using HotCocoa Laying out the views 200 speak to you 201 9.4 10 Windows and controls ■ Summary ■ 193 200 Making your application 202 MacRuby testing 203 10.1 10.2 10.3 10.4 Testing MacRuby applications with MiniTest 203 Installing and configuring MiniTest 205... at www.manning.com/MacRubyinAction Software requirements An Intel-based Macintosh running OS X 10.6 or higher is required to develop MacRuby applications You also need to download MacRuby, but it’s freely available at http:/ /macruby. org The book offers full coverage of MacRuby and Xcode 4 Author Online Purchase of MacRuby in Action includes free access to a private web forum run by Manning Publications... can’t follow along? www.it-ebooks.info Introducing MacRuby 1.1.2 5 Setting up your environment Install the Xcode development environment first It’s best to install MacRuby after you have Xcode set up on your machine If you don’t install in this order, tools such as Interface Builder (which is now built into Xcode 4) won’t be able to recognize your MacRuby code INSTALLING XCODE Registered Apple Developers... you’ll be able to pick any sections in the rest of the book and learn about the areas that are most interesting or relevant to you www.it-ebooks.info www.it-ebooks.info Introducing MacRuby This chapter covers ■ Exploring and installing MacRuby ■ Important Cocoa concepts ■ Objective-C and Ruby fundamentals ■ MacRuby syntax and methods ■ Developing with the Xcode IDE MacRuby gives you the ability to write... Using KVO to implement observers 128 Adding and removing observers 128 Manually notifying observers of changes 129 Responding to observed objects 130 ■ ■ 6.3 Building out the Product Inventory application 131 Creating the user interface 131 Using KVC to retrieve product information 132 Adding features with KVC and KVO 137 ■ ■ 6.4 7 Summary 140 Implementing persistence with Core Data 141 7.1 Introducing... 154 157 Filtering and sorting with predicates and descriptors 157 Fetching objects from Core Data 158 7.5 Creating a Core Data version of the Todo List application Building the user interface 160 Creating the tasks controller 161 Connecting the interface to the controller 164 Running the application and inspecting the persistent store 166 ■ ■ 7.6 8 Summary 167 Core Animation basics 168 8.1 Introduction... you, the reader, creating amazing Cocoa applications using MacRuby by the end of the book Throughout the book, you’ll learn in the ins and outs of MacRuby while exploring the Cocoa framework, design patterns, system scripting, testing, and getting your application into the Mac App Store We know that sometimes the best way to learn is to get your feet wet That’s why you’ll be creating useful Mac applications... system 3 www.it-ebooks.info 4 1.1 CHAPTER 1 Introducing MacRuby Introducing MacRuby MacRuby is an Apple-sponsored development project Over the years, Apple has shown support for Ruby as a language, and, since 2002, Apple has included Ruby as part of the Mac OS X operating system Apple bundled a Ruby Scripting Bridge implementation called RubyCocoa with Mac OS X Leopard Prior to MacRuby, RubyCocoa was... and the Cocoa framework together In this section, you’ll learn how MacRuby is different from past attempts at combining Ruby and Objective-C and what makes it such a great language We’ll also jump right into getting MacRuby installed onto your system and introduce you to MacRuby s class structure Let’s set the stage for MacRuby 1.1.1 The MacRuby difference The goal of MacRuby is to provide an implementation... of the book MacRuby in Action is also a more approachable introduction to Cocoa development than traditional Objective-C books Throughout the book, we explore practical code examples that you’ll face when creating your own applications MacRuby in Action can act as a guide for using MacRuby and Cocoa from the ground up, or you can use it as a reference if you’re looking to dive deeper into MacRuby xvi . MANNING Brendan G. LimWITH Jerry Cheung AND Jeremy McAnally IN ACTION www.it-ebooks.info MacRuby in Action www.it-ebooks.infowww.it-ebooks.info MacRuby. illustration xxPART 1 STARTING WITH MACRUBY 11 Introducing MacRuby 31.1 Introducing MacRuby 4The MacRuby difference 4■Setting up your environment 5Hello
- Xem thêm -

Xem thêm: Tài liệu MacRuby in Action pptx, Tài liệu MacRuby in Action pptx, Tài liệu MacRuby in Action pptx, 2 Cocoa: What you need to know, 3 Objective-C and Ruby: what you need to know, A.1 Before, there was AppleScript

Mục lục

Xem thêm

Gợi ý tài liệu liên quan cho bạn