my iphone apps
ctrl-drag objects into your view to code in your controller(outlets and actions)
option click to get help in your code.
@interface .h
@implementation .m
add a private @interface to .m
pointers to an object, type id or a static type(eg UIButton *)
invoke a method, using square bracket [] notation
dot notation for property
lazilly instantiate an object by implementing your own @property getter
wrap a primitive type (double) in an object (using NSNumber)
constant NSString @""
当你拖拽ui component 进入controller.h时, 系统会生成一个public property IBOutlet.(connection 类型为Outlet)
@property (weak, nonatomic) IBOutlet UILabel *display;
剩下的 你需要在controller.m 文件中
@synthesize 分配一下storage
@synthesize display = _display;
当你拖拽一个ui component 进入controller.m时,系统知道你要生成相应ui的action(connection 类型为Action)
- (IBActoin) digitPressed: (UIButton * id) sender { NSString * digit = [sender currentTitle]; self.display.text = [self.display.text stringByAppendingString:digit]; }
NSLog:
%@ 表示一个对象,就像%d 表示数字,%g 表示float 一样
to declare private property in controller.m file
@interface CalculatorViewController() @property (nonatomic) BOOL isInTheMiddle; @end