TTGDeallocTaskHelper 0.1.1

TTGDeallocTaskHelper 0.1.1

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布最新发布2017年3月

zekunyan 维护。



是什么

TTGDeallocTaskHelper 可以在对象析构后执行任务。

要求

  • iOS 7
  • macOS 10.8
  • tvOS 9.0
  • watchOS 2.0

安装

TTGDeallocTaskHelper 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod "TTGDeallocTaskHelper"

用法

#import "NSObject+TTGDeallocTaskHelper.h"

// Some object
id object;

// Add dealloc task
[object ttg_addDeallocTask:^(__unsafe_unretained id object, NSUInteger identifier) {
    // After object dealloc, do you job.
    // ...
}];

// object has been released. And the tasks will be performed.
object = nil;

API

回调块定义。

typedef void (^TTGDeallocTaskBlock)(__unsafe_unretained id object, NSUInteger identifier);

添加析构任务。

/**
 *  Add dealloc task to object.
 *
 *  @param taskBlock The dealloc task
 *
 *  @return The task identifier
 */
- (NSUInteger)ttg_addDeallocTask:(TTGDeallocTaskBlock)taskBlock;

通过标识符移除特定任务。

/**
 *  Remove task by identifier.
 *
 *  @param identifier The task identifier
 *
 *  @return Remove success or not
 */
- (BOOL)ttg_removeDeallocTaskByIdentifier:(NSUInteger)identifier;

移除所有析构任务。

/**
 *  Remove all dealloc tasks.
 */
- (void)ttg_removeAllDeallocTasks;

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

作者

zekunyan,

许可

TTGDeallocTaskHelper 根据 MIT 许可证提供。查看 LICENSE 文件以获取更多信息。