观察者模式

通知   

KVO(Key-Value Observing)

NSString *value = [NSStringstringWithFormat:@"%d",(int)_mySlider.value];

NSLog(@"%@",[selfvalueForKeyPath:@"myTxt.text"]);

NSString *keyPath = @"myTxts.text";

[self setValue:value forKeyPath:keyPath];
 
 
KVC(Key-Value Coding)
 
===========1:
//加一个检测textFiled
 

    [self addObserver:selfforKeyPath:@"myTxt.text"options:

     NSKeyValueObservingOptionOld||NSKeyValueObservingOptionNewcontext:nil];
===========2:

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

{

    NSLog(@"1");

    NSLog(@"%@",change);

}
 
适配器模式
协议
posted @ 2013-02-21 10:59  言程序  阅读(199)  评论(0)    收藏  举报