Latest 1.0.4
Homepage https://github.com/darrarski/DRObservableArray
License MIT
Platforms ios 8.0, osx 10.11, requires ARC
Authors

Version
License
Platform
codebeat
Build Status

Observable array and observable mutable array protocols with generic implementations in Objective-C.

DRObservableArray helps to create bindings with mutable ordered collecions. For example, you can bind models (or view models) array to UITableView, so it automaticlally updates with animation whenever you modify the array.

Usage

TL;DR: Check out included example project.

Library consists of three base protocols:

Protocol Description
DRObservableArray Defines ordered collection that you can subscribe to in order be notified whenever its content changes.
DRObservableMutableArray Defines ordered collection that you can modify using provided methods.
DRObservableArrayObserver Defines ordered collection observer that gets notified whenever collection changes.

You can implement your own collection, or use provided one:

Collection Description
DRGenericObservableArray Acts like NSMutableArray. Implements both DRObservableArray and DRObservableMutableArray protocols.

You can implement your own observer, or use provided one:

Observer Description
DRObservableArrayTableViewUpdater Updates UITableView section automatically whenever observable array is modified. iOS only.
DRObservableArrayCollectionViewUpdater Updates UICollectionView section automatically whenever observable array is modified. iOS only.

When you need to subscribe for collection changes, add an observer to collection like this:

id <DRObservableArray> collection = ...
id <DRObservableArrayObserver> observer = ...
[collection.observers addObserver:observer];

To avoid retain cycle issues, adding observer to collection creates weak reference between collection and observer.

Collection will notify its observers using DRObservableArrayObserver protocol methods when an object is added to, removed from, replaced or moved in collection.

Instalation

You can integrate DRObservableArray with your project using CocoaPods. To do so, you will need to add the following line to your Podfile:

pod 'DRObservableArray', '~> 1.0'

Which creates dependecy for version >= 1.0.0 and < 2.0.0

You can also download zip archive of given release from releases page.

License

The MIT License (MIT) – check out included LICENSE file

Latest podspec

{
    "name": "DRObservableArray",
    "version": "1.0.4",
    "summary": "Observable array and observable mutable array protocol with generic implementations",
    "homepage": "https://github.com/darrarski/DRObservableArray",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Dariusz Rybicki": "[email protected]"
    },
    "social_media_url": "https://twitter.com/darrarski",
    "source": {
        "git": "https://github.com/darrarski/DRObservableArray.git",
        "tag": "v1.0.4"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0",
        "osx": "10.11"
    },
    "source_files": "DRObservableArray/Common/*.{h,m}",
    "ios": {
        "source_files": "DRObservableArray/iOS/*.{h,m}"
    },
    "osx": {
        "source_files": "DRObservableArray/macOS/*.{h,m}"
    }
}

Pin It on Pinterest

Share This