Coder Social home page Coder Social logo

timoman / apasyncdictionary Goto Github PK

View Code? Open in Web Editor NEW

This project forked from classkick/apasyncdictionary

0.0 1.0 0.0 28 KB

Thread safe asynchronous access to NSMutableDictionary

License: MIT License

Ruby 4.56% Objective-C 48.92% Objective-C++ 46.52%

apasyncdictionary's Introduction

APAsyncDictionary is a wrapper on NSMutableDictionary that performs actions in own dispatch queue and return results to caller's thread. And it could be very useful when application uses dictionary concurrently from different threads.

Build Status

Features

  • Thread safety
  • Get object for key asynchronously
  • Set object for key
  • Set objects and keys from any NSDictionary
  • Remove object for key
  • Remove objects for NSArray of keys
  • Remove all objects for all keys
  • Get objects count asynchronously
  • Get all keys asynchronously
  • Get all objects asynchronously

Installation

Add APAsyncDictionary pod to Podfile

Using

// instantiation
APAsyncDictionary *dictionary = [[APAsyncDictionary alloc] init];
...
// get object for key
__block id someObject;
[dictionary objectForKey:@"key" callback:^(id <NSCopying> key, id object)
{
    someObject = object;
    // do something with object
}];
...
// get object for key synchronously
someObject = [dictionary objectForKeySynchronously:@"key"];
...
// set object
[dictionary setObject:object forKey:@"key"];
...
// set objects and keys from dictionary
[dictionary setObjectsAndKeysFromDictionary:@{@"key1" : object1, @"key2" : object2}];
...
// remove object for key
[dictionary removeObjectForKey:@"key"];
...
// remove objects for keys from array
[dictionary removeObjectsForKeys:@[@"key1", @"key2"]];
...
// remove all objects
[dictionary removeAllObjects];
...
// get objects count
[dictionary objectsCountCallback:^(NSUInteger count)
{
    // do something with count    
}];
...
// get objects count synchronously
NSUInteger count = [dictionary objectsCountSynchronously];
...
// all keys
[dictionary allKeysCallback:^(NSArray *keys)
{
    // do something with keys
}];
...
// all objects
[dictionary allObjectsCallback:^(NSArray *objects)
{
    // do something with objects
}];

History

Version 0.0.6

  • Improved read access performance

Version 0.0.5

  • Fixed Analyzer warning

Version 0.0.4

  • Added method to get object for key synchronously
  • Added method to get objects count synchronously

Version 0.0.3

  • Public release

githalytics.com alpha

If you have improvements or concerns, feel free to post an issue and write details.

Check out all Alterplay's GitHub projects. Email us with other ideas and projects.

apasyncdictionary's People

Contributors

belkevich avatar slavabushtruk avatar timoman avatar thmartin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.