Home Page Icon
Home Page
Table of Contents for
IX. State Of Object
Close
IX. State Of Object
by Carlo Chung
Pro Objective-C Design Patterns for iOS
Copyright
About the Author
About the Technical Reviewer
Acknowledgments
Preface
I. Getting Your Feet Wet
1. Hello, Design Patterns!
1.1. What This Book Is
1.2. What You Need Before You Can Begin
1.3. What You Need to Know Before You Can Begin
1.4. Design Déjà-vu
1.5. The Origin of Design Patterns - Model, View, and Controller (MVC)
1.5.1. Encapsulating Data and Basic Behaviors In Model Objects
1.5.2. Presenting Information to the User with View Objects
1.5.3. Tying up the Model to the View with Controller Objects
1.5.4. MVC as a Compound Design Pattern
1.6. Issues That Can Affect Your Design
1.6.1. Programming To An Interface, Not An Implementation
1.6.2. @protocol vs. Abstract Base Class (ABC)
1.6.3. Object Composition vs. Class Inheritance
1.7. Objects and Classes Used in this Book
1.7.1. Class Diagram
1.7.1.1. Protocol, Abstract Class, Concrete Class, and Category
1.7.1.2. Instantiation
1.7.1.3. Inheritance
1.7.1.4. Acquaintance
1.7.1.5. Aggregation
1.7.1.6. Pseudocode
1.7.2. Object Diagram
1.8. How the Patterns are Organized
1.9. Summary
2. A Case Study: Designing an App
2.1. Conceptualizing the Ideas
2.2. Designing the Look-and-Feel
2.3. Architectural Design
2.3.1. View Management
2.3.1.1. Transition from One View to Another
2.3.1.2. Using a Mediator to Coordinate View Transitions
2.3.2. Scribble Representation
2.3.2.1. "What" Can Be Drawn Onscreen?
2.3.2.2. Representing Marks with a Composite Structure
2.3.2.3. Drawing a Scribble
2.3.3. Representation of a Saved Scribble
2.3.3.1. Capturing the State of a Scribble
2.3.3.2. Restoring the State of a Scribble
2.3.4. User Operations
2.3.4.1. Browsing a List of Scribble Thumbnails
2.3.4.2. Undo/Redo Scribbling
2.3.4.3. Changing Stroke Colors and Sizes
2.3.4.4. Deleting the Current Scribble Onscreen
2.4. Reviewing the Patterns Used
2.5. Summary
II. Object Creation
3. Prototype
3.1. What Is the Prototype Pattern?
3.2. When Would You Use the Prototype Pattern?
3.3. Shallow Copying vs. Deep Copying
3.4. Using Object Copying in the Cocoa Touch Framework
3.5. Implementing the Copy Method for the Mark Aggregate
3.6. Using a Cloned Mark As a "Pattern Template"
3.7. Summary
4. Factory Method
4.1. What Is the Factory Method Pattern?
4.2. When Would You Use the Factory Method?
4.3. Why Is It a Safe Approach to Creating Objects?
4.4. Generating Different Canvases in TouchPainter
4.4.1. Using Canvases
4.5. Using Factory Methods Within the Cocoa Touch Framework
4.6. Summary
5. Abstract Factory
5.1. Applying the Abstract Factory to the TouchPainter App
5.2. Using the Abstract Factory Within the Cocoa Touch Framework
5.3. Summary
6. Builder
6.1. What Is the Builder Pattern?
6.2. When Would You Use the Builder Pattern?
6.3. Building Characters in a Chasing Game
6.4. Summary
7. Singleton
7.1. What Is the Singleton Pattern?
7.2. When Would You Use the Singleton Pattern?
7.3. Implementing a Singleton in Objective-C
7.4. Subclassing a Singleton
7.5. Thread Safety
7.6. Using Singletons in the Cocoa Touch Framework
7.6.1. Using the UIApplication Class
7.6.2. Using the UIAccelerometer Class
7.6.3. Using the NSFileManager Class
7.7. Summary
III. Interface Adaptation
8. Adapter
8.1. What Is the Adapter Pattern?
8.2. When Would You Use the Adapter Pattern?
8.3. So You Know Delegation
8.4. Implementing the Adapter Pattern with Objective-C Protocol
8.4.1. Designing and Implementing a Stroke Color Changing Mechanism
8.4.1.1. Defining SetStrokeColorCommandDelegate As a Target
8.4.1.2. Implementing SetStrokeCommand As a Client
8.4.1.3. Creating CommandSlider As an Adaptee
8.4.1.4. Using PaletteViewController As an Adapter
8.5. Implementing the Adapter Pattern with Objective-C Blocks in iOS 4
8.5.1. Declaring a Block Reference
8.5.2. Creating a Block
8.5.3. Using a Block As an Adapter
8.6. Summary
9. Bridge
9.1. What Is the Bridge Pattern?
9.2. When Would You Use the Bridge Pattern?
9.3. Creating a Virtual Emulator for iOS
9.4. Summary
10. Façade
10.1. What Is the Façade Pattern?
10.2. When Would You Use the Façade Pattern?
10.3. Providing a Simplified Interface to a Set of Interfaces in the Subsystem
10.4. Using the Façade Pattern in the TouchPainter App
10.5. Summary
IV. Decoupling of Objects
11. Mediator
11.1. What Is the Mediator Pattern?
11.2. When Would You Use the Mediator Pattern?
11.3. Managing View Transition in the TouchPainter App
11.3.1. The Troubles of Modifying the Transition Logic
11.3.2. Centralizing the Flow of the UI Traffic
11.3.3. Using the CoordinatingController in the Interface Builder
11.4. Summary
12. Observer
12.1. What Is the Observer Pattern?
12.2. When Would You Use the Observer Pattern?
12.3. Using the Observer Pattern in Model-View-Controller
12.4. Using the Observer Pattern in the Cocoa Touch Framework
12.4.1. Notifications
12.4.2. Key-Value Observing
12.5. Updating Strokes on the CanvasView in TouchPainter
12.6. Summary
V. Abstract Collection
13. Composite
13.1. What Is the Composite Pattern?
13.2. When Would You Use the Composite Pattern?
13.3. Understanding the Use of Mark in TouchPainter
13.4. Using Composites in the Cocoa Touch Framework
13.5. Summary
14. Iterator
14.1. What Is the Iterator Pattern?
14.2. When Would You Use the Iterator Pattern?
14.3. Using Iterators in the Cocoa Touch Framework
14.3.1. NSEnumerator
14.3.2. Block-Based Enumeration
14.3.3. Fast Enumeration
14.3.4. Internal Enumeration
14.4. Enumerating Vertices of a Scribble
14.4.1. Enumerating Vertices of a Scribble (Internally)
14.5. Summary
VI. Behavioral Extension
15. Visitor
15.1. What is the Visitor Pattern?
15.2. When Would You Use the Visitor Pattern
15.3. Rendering Marks in TouchPainter with Visitors
15.4. What Else Can A Visitor Do?
15.5. Can't I Just Use Categories Instead?
15.6. Summary
16. Decorator
16.1. What Is the Decorator Pattern?
16.2. When Would You Use the Decorator Pattern?
16.3. Changing the "Skin" vs. "Guts" of an Object
16.4. Creating Image Filters for UIImage
16.4.1. Implementing Decorators with True Subclasses
16.4.2. Implementing Decorators with Categories
16.5. Summary
17. Chain of Responsibility
17.1. What Is the Chain of Responsibility Pattern?
17.2. When Would You Use the Chain of Responsibility Pattern?
17.3. Using the Chain of Responsibility Pattern in an RPG
17.4. Summary
VII. Algorithm Encapsulation
18. Template Method
18.1. What Is the Template Method Pattern?
18.2. When Would You Use the Template Method?
18.3. Using the Template Method to Make a Sandwich
18.4. Ensuring That the Template Method Is Working
18.5. Adding an Extra Step to the Template Method
18.6. Using the Template Method in the Cocoa Touch Framework
18.6.1. Custom Drawing in the UIView Class
18.6.2. Other Template Method Implementations in Cocoa Touch
18.7. Summary
19. Strategy
19.1. What Is the Strategy Pattern?
19.2. When Would You Use the Strategy Pattern?
19.3. Applying Validation Strategies in UITextField
19.4. Summary
20. Command
20.1. What Is the Command Pattern?
20.2. When Would You Use the Command Pattern?
20.3. Using the Command Pattern in the Cocoa Touch Framework
20.3.1. NSInvocation Objects
20.3.2. NSUndoManager
20.3.2.1. Registering Undo Command Operations
20.4. Implementing Undo/Redo in TouchPainter
20.4.1. Implementing Drawing/Undrawing with NSUndoManager
20.4.1.1. Adding Methods for Generating Drawing/Undrawing Invocations
20.4.1.2. Adding Methods for Registering Undo/Redo Operations in NSUndoManager
20.4.1.3. Modifying Touch Event Handlers for Invocations
20.4.2. Home-Brewing Your Own Drawing/Undrawing Infrastructure
20.4.2.1. Designing a Command Infrastructure
20.4.2.2. Implementing the Command Classes
20.4.2.3. Modifying CanvasViewController for the Commands
20.4.3. Allowing the User to Activate Undo/Redo
20.5. What Else Can a Command Do?
20.6. Summary
VIII. Performance and Object Access
21. Flyweight
21.1. What Is the Flyweight Pattern?
21.2. When Would You Use the Flyweight Pattern?
21.3. Creating a Hundred-Flower Pool
21.3.1. Designing and Implementing Sharable Flowers
21.3.1.1. Implementing the FlowerView Class
21.3.1.2. Implementing the FlowerFactory Class
21.3.1.3. How Are FlowerView Objects Shared?
21.3.1.4. Implementing Client Code
21.4. Summary
22. Proxy
22.1. What Is the Proxy Pattern?
22.2. When Would You Use the Proxy Pattern?
22.3. Lazy-Loading an Image with a Virtual Proxy
22.3.1. Designing and Implementing a Scribble Thumbnail View
22.3.1.1. Implementing the ScribbleThumbnailView Class
22.3.1.2. Implementing the ScribbleThumbnailViewImageProxy Class
22.4. Using a Proxy Pattern in the Cocoa Touch Framework
22.5. Summary
IX. State Of Object
23. Memento
23.1. What's the Memento Pattern?
23.2. When Would You Use the Memento Pattern?
23.3. Using the Memento Pattern in TouchPainter
23.3.1. Saving a Scribble
23.3.2. Restoring a Scribble
23.3.3. Designing and Implementing ScribbleMemento
23.3.3.1. Implementing the ScribbleMemento Class
23.3.3.2. Modifying the Scribble Class
23.3.3.3. Putting Everything Together with a Caretaker
23.4. The Memento Pattern in the Cocoa Touch Framework
23.5. Summary
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
22. Proxy
Next
Next Chapter
23. Memento
Part IX. State Of Object
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset