Cocoa Design pattern

摘要: @interface PayCalculator : NSObject{IBOutlet NSTextField *employeeNameField;IBOutlet NSFormCell *hourlyRateField;IBOutlet NSFormCell *hoursWorkedField;IBOutlet NSFormCell *standardHoursInPeriodField;IBOutlet NSTextField *payAmountField;IBOutlet NSButton *employeeIsExemptButton;}- (IBAction)calculate 阅读全文
posted @ 2012-07-02 16:09 grep 阅读(203) 评论(0) 推荐(0) 编辑

Design revisited

摘要: the goal of the design is to solve a problem in a general, reusable way.several guiding principles of design help ensure that the patterns are flexible and applicable in many contexts.Minimize CouplingCoupling between classes should be minimized. Coupling refers to dependencies between objects. When 阅读全文
posted @ 2012-07-02 09:53 grep 阅读(135) 评论(0) 推荐(0) 编辑

Layer Filters

摘要: Core animation provides a means to bridge into other core capabilities.Pratically, this means that you can apply, for example, a Gaussian blur to a layer's contents. 阅读全文
posted @ 2012-06-27 19:09 grep 阅读(200) 评论(0) 推荐(0) 编辑

Keyframe Animation- Transform

摘要: The designated initializer for a CALayer is simply init. After you instantiate a layer, you set its size, position, and contents.-(id) initWithFrame: (CGRect) r{self = [super initWithFrame:r];if(self){[self setBackgroundColor:[UIColor clearColor]];[self setCircleColor:[UIColor lightGrayColor]];boxLa 阅读全文
posted @ 2012-06-27 10:53 grep 阅读(740) 评论(0) 推荐(0) 编辑

Cocoa Fundamentals Guide

摘要: Chain of message disptach tableEvery Objective-C object hides a data structure whose first member - or instance variable - is the isa pointer.The isa pointer, as the name suggests, points to the object's class, which is an object in its own right and is compiled from the class definition. The cl 阅读全文
posted @ 2012-06-21 09:11 grep 阅读(310) 评论(0) 推荐(0) 编辑

Responder Chain

摘要: The Chain of Responsibility pattern is designed to decouple a message's sender from the receiver. A message or event is passed down a linked list of objects until one of them handles the message,giving multiple objects the opportunity to handle or ignore the message.In Cocoa, all objects that re 阅读全文
posted @ 2012-06-20 15:06 grep 阅读(339) 评论(0) 推荐(0) 编辑

singleton with GCD

摘要: A calling object cannot instantiate a singleton object through other means of allocation. Otherwise, multiple instances of the singleton class could be created.Restrictions on instantiating a singleton object should also coexist with the reference counting memory models.Before GCD, we need to use sy 阅读全文
posted @ 2012-06-19 14:18 grep 阅读(407) 评论(0) 推荐(0) 编辑

Core Animation

摘要: In a view hierarchy, sibling views typically do not have to overlapping bounds. For instance, imagine a view with two subviews that are buttons. It would confuse and frustrate the user when buttons are overlapping and obscuring each other.The layer hierarchy, however, is a different story. Siblings 阅读全文
posted @ 2012-06-17 21:03 grep 阅读(731) 评论(0) 推荐(0) 编辑

Saving,Loading, and Multitasking

摘要: Every iOS application has its own application sandbox. An application sandbox is a directory on the filesystem that is barricaded from the rest of the filesystem. Your application must stay in its sandbox, and no other application can access your sandbox.The application sandbox contains a number of 阅读全文
posted @ 2012-06-17 10:45 grep 阅读(386) 评论(0) 推荐(0) 编辑

Camera

摘要: Taking pictures and UIImagePickerControllerNow you need a button to initiate the photo-taking process. It would be nice put this button on the navigation bar, but we will need the navigation bar for another button later. Instead, we will create an instance of UIToolbar and place it at the bottom of 阅读全文
posted @ 2012-06-16 17:35 grep 阅读(287) 评论(0) 推荐(0) 编辑