• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Objective-C
  • License
    Other
  • Created over 10 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

iOS port of Hoodie http://hood.ie/

HOOHoodie

Version Platform Build Status

Hoodie-iOS is a library which connects to the Hoodie backend API. (See http://hood.ie/ for more information on Hoodie) As local storage the awesome Couchbase Lite framework is used, which also handles the replication to and from the server.

It doesn't support the full API and functionality yet (see issues to see what's still missing). Currently supported functionality:

  • Anonymous Sign up
  • Sign up (sign up with username and password)
  • Sign in
  • Sign out
  • Change password of account
  • Saving new objects
  • Removing objects
  • Updating objects
  • Retrieving all saved objects of the user by type
  • Replication to and from user database on the server

Usage

To run the example project; clone the repo, and run pod install from the Example directory first.

Then install the Hoodie Server and create a new Hoodie app, which will be the backend for your iOS app (see http://hood.ie/#installation for instructions).

Installation

HOOHoodie is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "HOOHoodie"

Documentation

To get started with Hoodie-iOS, first install the Hoodie Server and create and start a new Hoodie app (see http://hood.ie/#installation for instructions).

####Creating a new hoodie instance

#import "HOOHoodie.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Create new Hoodie instance with URL to Hoodie
    self.hoodie =[[HOOHoodie alloc] initWithBaseURLString:@"http://localhost:6001"];
}

####Anonymous sign up

[self.hoodie.account anonymousSignUpOnFinished:^(BOOL signUpSuccessful, NSError *error) {               

            }];

####Sign up new user

    [self.hoodie.account signUpUserWithName:@"username"
                                   password:@"password"
                                   onSignUp:^(BOOL signUpSuccessful, NSError *error) {
    }];

####Sign in existing user

If the user signed in succesfully, Hoodie signs in the user automatically on that device on startup, until the user signs out explicitly.

    [self.hoodie.account signInUserWithName:@"username"
                                   password:@"password"
                                   onSignIn:^(BOOL signInSuccessful, NSError *error) {
    }];

####Sign out current user

    [self.hoodie.account signOutOnFinished:^(BOOL signOutSuccessful, NSError *error) {
        [self updateSignInStateDependentElements];
    }];

####Change password of existing user

    [self.hoodie.account changeOldPassword:self.currentPasswordInputField.text
                             toNewPassword:self.passwordInputField.text
                          onPasswordChange:^(BOOL passwordChangeSuccessful, NSError *error) {
                          }];

####Saving objects

The Hoodie store currently only accepts NSDictionaries as objects to store.

Reserved keys that are set automatically by the Hoodie store are: _id, _rev, type, createdBy, createdAt, updatedAt

    NSDictionary *newTodo = @{@"title": @"This is a todo"};
    [self.hoodie.store saveObject:newTodo 
                         withType:@"todo"
                           onSave:^(NSDictionary *object, NSError *error) {
    }];

####Update existing object

 [self.store updateObjectWithID:todoItem[@"id"]
                        andType:todoItem[@"type"]      
                 withProperties:@{@"title": textField.text}
                       onUpdate:^(NSDictionary *updatedObject, NSError *error) {
}];

####Remove object

 [self.store removeObjectWithID:todoItem[@"id"]
                        andType:todoItem[@"type"]                                                                                           onRemoval:^(BOOLremovalSuccessful,NSError*error) {
}];

####Retrieving objects

    NSArray *myTodos = [self.store findAllByType:@"todo"];

Source

The source code is available on Github: https://github.com/kaalita/Hoodie-iOS

Contributing

Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.

Author

Katrin Apel, [email protected]

License

HOOHoodie is available under the Apache 2.0 license. See the LICENSE file for more info.