iOS之设计模式闻道丶iOS(大杂烩)将来跳槽用

03-设计模式(包括KVO/KVC)

2016-11-07  本文已影响249人  面试题大神

iOS开发常用设计模式?

详细blog链接

  1. MVC模式
  2. MVVM模式
  3. 代理模式
  4. 单例模式
  5. 工厂模式
  6. 装饰者模式
  7. 观察者模式(KVO和通知中心)
  8. KVC模式

对MVC的理解

MVC中Model,View, Controller之间如何通信?

对MVVM的理解以及如何实践

MVC 和MVVM的区别


对代理模式的理解

使用代理模式的注意事项?


对单例的理解

单例中如何保证只有一个实例对象

使用单例模式时要注意什么?


对工厂模式的理解

#import "OperationFactory.h"
#import "Operation.h"
#import "AddOperation.h"
#import "MinusOperation.h"

@implementation OperationFactory

+ (id)operationWithType:(OperationType)type
{
    Operation *operation = nil;
    
    if (type == OperationTypeAdd)
    {
        operation = [[AddOperation alloc] init];
    }
    else
    {
        operation = [[MinusOperation alloc] init];
    }
    
    return operation;
}

对装饰模式的理解

详细博客link

@implementation Decorater
- (void)setPerson:(Person *)person
{
    _person = person;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    Decorater *decorater = [[Decorater alloc] init];
    
    Student *student = [[Student alloc] init];
    decorater.person = student;
    [decorater.person eat];
    
    Teacher *teacher = [[Teacher alloc] init];
    decorater.person = teacher;
    [decorater.person eat];
}

工厂模式,装饰模式常用于哪些场景?


对观察者模式的理解

KVO与NSNotification有什么区别?

在哪些场景可以使用KVO和NSNotification?


KVC和KVO是什么, 有什么区别, 使用时需要注意什么?

KVO内部实现原理

详细博客Link

  Person *p1 = [[Person alloc] init];
 [p1 addObserver:self forKeyPath:@"age"
      options: NSKeyValueObservingOptionNew
      context:nil];

KVC内部实现原理

详细博客Link

使用KVC和KVO的好处?

一般在项目中哪些地方会用到KVC?

上一篇下一篇

猜你喜欢

热点阅读