TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2015 |
Maintained by Daniel Thengvall.
Create an enum in your project to serve as your object types, something like:
ExampleDataType.h view file
#import <Foundation/Foundation.h>
typedef enum ExampleDataType : NSUInteger {
TEST_TYPE
// todo: add more
} ExampleDataType;
Example.m view file
#import "DTAsyncIO.h"
#import "ExampleDataType.h"
#import "DTObservable.h"
...
- (void)writeExample {
[[DTAsyncIO write:@{@"4": @20} forType:TEST_TYPE] subscribe:[[DTSubscriber alloc] init:^(NSDictionary *data) {
BOOL fourTwenty = [data[@"4"] intValue] == 20;
NSLog(@"does 4 == 20? %@", fourTwenty ? @"YES" : @"NO");
} onError:^(NSError *error) {
NSLog(@"Error! %@", error);
}]];
}
- (void)readExample {
[[DTAsyncIO read:TEST_TYPE] subscribe:[[DTSubscriber alloc] init:^(NSDictionary *data) {
NSLog(@"%@", data[@"4"]); // 20
} onError:^(NSError *error) {
NSLog(@"Error! %@", error);
}]];
}
DTAsyncIO is available through GitHub. To install it, simply add the following line to your Podfile:
pod 'DTAsyncIO', '0.2.20'
You can easily update your project to use CocoaPods:
sudo gem install cocoapods
platform :ios, deployment_target: '8.0'
pod 'DTAsyncIO', '0.2.20'
pod install
DTAsyncIO returns an NSError object when an NSException or other error has occurred.
int code = error.code;
NSString *message = error.userInfo[@"message"];
code | |
---|---|
-1 | Read error |
-2 | Write error |
-3 | Error generating key |
DTHENG, [email protected]
DTAsyncIO is available under the MIT license. See the LICENSE file for more info.