Latest 0.1.0
License MIT
Platforms ios 8.0


ReuseableQueue is a simple, private api free queue you can use to reuse every object.

How to get startet

install via CocoaPods

The best way to install BRReuseableQueue is via CocoaPods.


pod 'BRReuseQueue/Swift'


pod 'BRReuseQueue/OBJC'

Swift Usage

// Import BRReusableQueue
import BRReusableQueue

// get hold of your queue
let reusableQueue = BRReusableQueue.sharedQueue // or you can create your own one

// enqueue an object you don't need
let reusableObject = ReusableClass()

// dequeue the object

Objective-C Usage

// Import BRReusableQueue
@import BRReusableQueue;

// get hold of your queue
ReusableQueue *reusableQueue = [BRReusableQueue sharedQueue]; // or you can create your own one

// enqueue an object you don't need
ReusableClass *reusableObject = [ReusableClass new];
[reusableQueue enqueueReusable:reusableObject];

// dequeue the object
[reusableQueue dequeueReusableWithClass:ReusableClass];

Custom Reusable Class

All objects stored in a ReusableQueue must implement the Reusable protocol. All methods in the protocol are optional and are there to help you customize the queue.

Custom reuseIdentifier

Per default the reuseIdentifier is the class name of an object. You can change that behavior by implementing the reuseIdentifier.

optional static func reuseIdentifier() -> String

Easy creation of objects

Per default you can only use the dequeueReusableWithIdentifier and dequeueReusableWithClass method to get hold of an object. Those methods return nil if there is no object in the queue for the given identifier.

The dequeueOrCreateReusableWithClass will dequeue an object and create a new one if none was found.

optional static func newForReuse() -> AnyObject?

Prepare for reuse

Every object that gets enqueued in the reusableQueue is called the prepareForReuse method. Use it to reset it to a default state and get rid of everything you don’t need.

optional func prepareForReuse() -> Void


Both variants (Swift/Objc) live side by side. The Objc variant exists so Objc only projects can use it without requiring the Swift runtime. The Swift variant exists because I wanted to play around in Swift.

This Setup makes testing a bit hard. The test code should test both variants the exact same way. To toggle between testing Swift / Objc code please change (un-)comment the line in BRReusableQueue-Bridging-Header.h and BRReusableQueueTests.swift:12. I am still searching for a way to optimize this.

Latest podspec

    "name": "BRReusableQueue",
    "module_name": "BRReusableQueue",
    "version": "0.1.0",
    "summary": "ReusableQueue is a simple, private api free queue you can use to reuse every object.",
    "description": "Whenever you struggle with performance of the creation of certain objects try to reuse them. This queue helps you to reuse every object you need to.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Cornelius Horstmann": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "subspecs": [
            "name": "Swift",
            "source_files": "BRReusableQueue/*.swift"
            "name": "OBJC",
            "source_files": "BRReusableQueue/*.{h,m}"

Pin It on Pinterest

Share This