观察者模式
通知
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);
}
适配器模式
协议