DTAsyncIO 0.2.20

DTAsyncIO 0.2.20

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Sep 2015

Maintained by Daniel Thengvall.



DTAsyncIO 0.2.20

  • By
  • DTHENG

Usage

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);
    }]];
}

Requirements

  • iOS 8 or greater

Installation

DTAsyncIO is available through GitHub. To install it, simply add the following line to your Podfile:

pod 'DTAsyncIO', '0.2.20'

Dont have a Podfile?

You can easily update your project to use CocoaPods:

  • Install the CocoaPods library:
sudo gem install cocoapods
  • Go to the directory where your .xcodeproj file is
  • Create a new file called Podfile
  • Update Podfile with:
platform :ios, deployment_target: '8.0'

pod 'DTAsyncIO', '0.2.20'
  • Now run this command:
pod install
  • From now on only open the .xcworkspace file in your project NOT .xcodeproj
  • Done!

Errors

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

Author

DTHENG, [email protected]

License

DTAsyncIO is available under the MIT license. See the LICENSE file for more info.