/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
/**
This macro ensures that key path exists at compile time.
Given a real receiver with a key path as you would call it, it verifies at compile time that the key path exists, without calling it.
For example:
FBKVOKeyPath(string.length) => @"length"
Or even the complex case:
FBKVOKeyPath(string.lowercaseString.length) => @"lowercaseString.length".
*/
#define FBKVOKeyPath(KEYPATH) \
@(((void)(NO && ((void)KEYPATH, NO)), \
({ const char *fbkvokeypath = strchr(#KEYPATH, '.'); NSCAssert(fbkvokeypath, @"Provided key path is invalid."); fbkvokeypath + 1; })))
/**
This macro ensures that key path exists at compile time.
Given a receiver type and a key path, it verifies at compile time that the key path exists, without calling it.
For example:
FBKVOClassKeyPath(NSString, length) => @"length"
FBKVOClassKeyPath(NSString, lowercaseString.length) => @"lowercaseString.length"
*/
#define FBKVOClassKeyPath(CLASS, KEYPATH) \
@(((void)(NO && ((void)((CLASS *)(nil)).KEYPATH, NO)), #KEYPATH))
NS_ASSUME_NONNULL_BEGIN
/**
Key provided in the @c change dictionary of @c FBKVONotificationBlock that's value represents the key-path being observed
*/
extern NSString *const FBKVONotificationKeyPathKey;
/**
@abstract Block called on key-value change notification.
@param observer The observer of the change.
@param object The object changed.
@param change The change dictionary which also includes @c FBKVONotificationKeyPathKey
*/
typedef void (^FBKVONotificationBlock)(id _Nullable observer, id object, NSDictionary<NSString *, id> *change);
/**
@abstract FBKVOController makes Key-Value Observing simpler and safer.
@discussion FBKVOController adds support for handling key-value changes with blocks and custom actions, as well as the NSKeyValueObserving callback. Notification will never message a deallocated observer. Observer removal never throws exceptions, and observers are removed implicitly on controller deallocation. FBKVOController is also thread safe. When used in a concurrent environment, it protects observers from possible resurrection and avoids ensuing crash. By default, the controller maintains a strong reference to objects observed.
*/
@interface FBKVOController : NSObject
///--------------------------------------
#pragma mark - Initialize
///--------------------------------------
/**
@abstract Creates and returns an initialized KVO controller instance.
@param observer The object notified on key-value change.
@return The initialized KVO controller instance.
*/
+ (instancetype)controllerWithObserver:(nullable id)observer;
/**
@abstract The designated initializer.
@param observer The object notified on key-value change. The specified observer must support weak references.
@param retainObserved Flag indicating whether observed objects should be retained.
@return The initialized KVO controller instance.
@discussion Use retainObserved = NO when a strong reference between controller and observee would create a retain loop. When not retaining observees, special care must be taken to remove observation info prior to observee dealloc.
*/
- (instancetype)initWithObserver:(nullable id)observer retainObserved:(BOOL)retainObserved NS_DESIGNATED_INITIALIZER;
/**
@abstract Convenience initializer.
@param observer The object notified on key-value change. The specified observer must support weak references.
@return The initialized KVO controller instance.
@discussion By default, KVO controller retains objects observed.
*/
- (instancetype)initWithObserver:(nullable id)observer;
/**
@abstract Initializes a new instance.
@warning This method is unavaialble. Please use `initWithObserver:` instead.
*/
- (instancetype)init NS_UNAVAILABLE;
/**
@abstract Allocates memory and initializes a new instance into it.
@warning This method is unavaialble. Please use `controllerWithObserver:` instead.
*/
+ (instancetype)new NS_UNAVAILABLE;
///--------------------------------------
#pragma mark - Observe
///--------------------------------------
/**
The observer notified on key-value change. Specified on initialization.
*/
@property (nullable, nonatomic, weak, readonly) id observer;
/**
@abstract Registers observer for key-value change notification.
@param object The object to observe.
@param keyPath The key path to observe.
@param options The NSKeyValueObservingOptions to use for observation.
@param block The block to execute on notification.
@discussion On key-value change, the specified block is called. In order to avoid retain loops, the block must avoid referencing the KVO controller or an owner thereof. Observing an already observed object key path or nil results in no operation.
*/
- (void)observe:(nullable id)object keyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options block:(FBKVONotificationBlock)block;
/**
@abstract Registers observer for key-value change notification.
@param object The object to observe.
@param keyPath The key path to observe.
@param options The NSKeyValueObservingOptions to use for observation.
@param action The observer selector called on key-value change.
@discussion On key-value change, the observer's action selector is called. The selector provided should take the form of -propertyDidChange, -propertyDidChange: or -propertyDidChange:object:, where optional parameters delivered will be KVO change dictionary and object observed. Observing nil or observing an already observed object's key path results in no operation.
*/
- (void)observe:(nullable id)object keyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options action:(SEL)action;
/**
@abstract Registers observer for key-value change notification.
@param object The object to observe.
@param keyPath The key path to observe.
@param options The NSKeyValueObservingOptions to use for observation.
@param context The context specified.
@discussion On key-value change, the observer's -observeValueForKeyPath:ofObject:change:context: method is called. Observing an already observed object key path or nil results in no operation.
*/
- (void)observe:(nullable id)object keyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(nullable void *)context;
/**
@abstract Registers observer for key-value change notification.
@param object The object to observe.
@param keyPaths The key paths to observe.
@param options The NSKeyValueObservingOptions to use for observation.
@param block The block to execute on notification.
@discussion On key-value change, the specified block is called. Inorder to avoid retain loops, the block must avoid referencing the KVO controller or an owner thereof. Observing an already observed object key path or nil results in no operation.
*/
- (void)observe:(nullable id)object keyPaths:(NSArray<NSString *> *)keyPaths options:(NSKeyValueObservingOptions)options block:(FBKVONotificationBlock)block;
/**
@abstract Registers observer for key-value change notification.
@param object The object to observe.
@param keyPaths The key paths to observe.
@param options The NSKeyValueObservingOptions to use for observation.
@param action The observer selector called on key-value change.
@discussion On key-value change, the observer's action selector is called. The selector provided should take the form of -propertyDidChange, -propertyDidChange: or -propertyDidChange:object:, where optional parameters delivered will be KVO change dictionary and object observed. Observing nil or observing an already observed object's key path results in no operation.
*/
- (void)observe:(nullable id)object keyPaths:(NSArray<NSString *> *)keyPaths options:(NSKeyValueObservingOpt
没有合适的资源?快使用搜索试试~ 我知道了~
iOS mvvm,map,mvc 源码demo
共439个文件
storyboard:158个
m:95个
h:95个
需积分: 0 10 下载量 165 浏览量
2017-11-04
16:37:19
上传
评论 1
收藏 1.01MB ZIP 举报
温馨提示
一篇很简单的文章,让我学会了mvvm,由于作者的github上的demo有问题,这个是修复好的demo。 转载:自简书,作者:远处山谷吹来的清风 MVC/MVP/MVVM 三种设计模式简介附demo http://www.jianshu.com/p/545f2b94ee3d
资源推荐
资源详情
资源评论
收起资源包目录
iOS mvvm,map,mvc 源码demo (439个子文件)
.DS_Store 6KB
FBKVOController.h 9KB
NSObject+FBKVOController.h 2KB
MVPPresenter.h 489B
MVVMViewModel.h 390B
KVOController.h 390B
MVCView.h 363B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
AppDelegate.h 277B
MVVMView.h 261B
MVPModel.h 247B
MVVMModel.h 244B
MVCModel.h 242B
MVPCell.h 227B
MVPViewController.h 219B
MVVMViewController.h 219B
MVCViewController.h 217B
ViewController.h 208B
Contents.json 585B
Contents.json 585B
Contents.json 585B
Contents.json 585B
共 439 条
- 1
- 2
- 3
- 4
- 5
资源评论
geniuskkbb
- 粉丝: 1
- 资源: 43
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功