key-value 监控实现 KVOController

码农软件 · 软件分类 · 其他(Others) · 2019-07-25 10:29:18

软件介绍

温馨提示:该项目除了使用 BSD 协议授权外,还需遵守附加的专利授权

Key-value 的监控是一个 MVC 应用中非常有用的技术。KVOController (来自 facebook)构建了一个基于 Cocoa 的 time-tested key-value 监控实现,提供简单方便、线程安全的 API。好处包括:

  • 使用 Blocks、自定义 Actions 或者 NSKeyValueObserving 回调进行通知.

  • 观测者移除时无异常

  • 控制器 dealloc 时隐式的观测者移除

  • 提升使用 NSKeyValueObservingInitial 的性能

  • 线程安全并提供在观测者恢复时额外的保护Thread-safety with special guards against observer resurrection – rdar://15985376.

使用方法:

// create KVO controller with observer
FBKVOController *KVOController = [FBKVOController controllerWithObserver:self];

// observe clock date property 
[KVOController observe:clock keyPath:@"date" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew block:^(ClockView *clockView, Clock *clock, NSDictionary *change) {

  // update clock view with new value
  clockView.date = change[NSKeyValueChangeNewKey];
}];

要求:

  • iOS 6 or later.

  • OS X 10.7 or later.

本文地址:https://codercto.com/soft/d/10894.html

Learning Web Design

Learning Web Design

Jennifer Niederst Robbins / O'Reilly Media / 2007-6-15 / USD 44.99

Since the last edition of this book appeared three years ago, there has been a major climate change with regard to web standards. Designers are no longer using (X)HTML as a design tool, but as a means......一起来看看 《Learning Web Design》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试