TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Alexey Belkevich.
APAsyncDictionary is a wrapper on NSMutableDictionary that performs actions in own serial queue and return results to caller's thread. And it could be very useful when application uses dictionary
concurrently from different threads.
NSDictionary
NSArray
of keysAdd APAsyncDictionary
pod to Podfile
// 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
}];
Version 0.0.5
Version 0.0.4
Version 0.0.3
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.