Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekunyan/ttgdealloctaskhelper
NSObject Category to add callback tasks when object dealloc.
https://github.com/zekunyan/ttgdealloctaskhelper
dealloc dealloc-tasks ios objective-c
Last synced: 3 months ago
JSON representation
NSObject Category to add callback tasks when object dealloc.
- Host: GitHub
- URL: https://github.com/zekunyan/ttgdealloctaskhelper
- Owner: zekunyan
- License: mit
- Created: 2016-07-17T07:56:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T08:46:30.000Z (almost 8 years ago)
- Last Synced: 2024-10-31T16:30:38.420Z (4 months ago)
- Topics: dealloc, dealloc-tasks, ios, objective-c
- Language: Shell
- Size: 41 KB
- Stars: 29
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TTGDeallocTaskHelper
[![CI Status](http://img.shields.io/travis/zekunyan/TTGDeallocTaskHelper.svg?style=flat)](https://travis-ci.org/zekunyan/TTGDeallocTaskHelper)
[![Version](https://img.shields.io/cocoapods/v/TTGDeallocTaskHelper.svg?style=flat)](http://cocoapods.org/pods/TTGDeallocTaskHelper)
[![License](https://img.shields.io/cocoapods/l/TTGDeallocTaskHelper.svg?style=flat)](http://cocoapods.org/pods/TTGDeallocTaskHelper)
[![Platform](https://img.shields.io/cocoapods/p/TTGDeallocTaskHelper.svg?style=flat)](http://cocoapods.org/pods/TTGDeallocTaskHelper)## What
TTGDeallocTaskHelper is useful to perform tasks after object dealloc.
## Requirements
* iOS 7
* macOS 10.8
* tvOS 9.0
* watchOS 2.0## Installation
TTGDeallocTaskHelper is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "TTGDeallocTaskHelper"
```## Usage
```
#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
Callback block definition.```
typedef void (^TTGDeallocTaskBlock)(__unsafe_unretained id object, NSUInteger identifier);
```Add dealloc task.
```
/**
* Add dealloc task to object.
*
* @param taskBlock The dealloc task
*
* @return The task identifier
*/
- (NSUInteger)ttg_addDeallocTask:(TTGDeallocTaskBlock)taskBlock;
```Remove specific task by identifier.
```
/**
* Remove task by identifier.
*
* @param identifier The task identifier
*
* @return Remove success or not
*/
- (BOOL)ttg_removeDeallocTaskByIdentifier:(NSUInteger)identifier;
```Remove all dealloc tasks.
```
/**
* Remove all dealloc tasks.
*/
- (void)ttg_removeAllDeallocTasks;
```## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Author
zekunyan, [email protected]
## License
TTGDeallocTaskHelper is available under the MIT license. See the LICENSE file for more info.