TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Dec 2014 |
Maintained by Katrin Apel.
Depends on: | |
AFNetworking | ~> 2.0 |
FMDB | ~> 2.3 |
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:
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).
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).
#import "HOOHoodie.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// This is the URL of the Hoodie API, after you started your Hoodie app
NSURL *baseURL = [NSURL URLWithString:@"http://localhost:6001/_api"];
// Create new Hoodie instance with URL to your Hoodie API
self.hoodie = [[HOOHoodie alloc] initWithBaseURL:baseURL];
}
[self.hoodie.account anonymousSignUpOnFinished:^(BOOL signUpSuccessful, NSError *error) {
}];
[self.hoodie.account signUpUserWithName:@"username"
password:@"password"
onSignUp:^(BOOL signUpSuccessful, NSError *error) {
}];
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) {
}];
[self.hoodie.account signOutOnFinished:^(BOOL signOutSuccessful, NSError *error) {
[self updateSignInStateDependentElements];
}];
[self.hoodie.account changeOldPassword:self.currentPasswordInputField.text
toNewPassword:self.passwordInputField.text
onPasswordChange:^(BOOL passwordChangeSuccessful, NSError *error) {
}];
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) {
}];
[self.store updateObjectWithID:todoItem[@"id"]
andType:todoItem[@"type"]
withProperties:@{@"title": textField.text}
onUpdate:^(NSDictionary *updatedObject, NSError *error) {
}];
[self.store removeObjectWithID:todoItem[@"id"]
andType:todoItem[@"type"] onRemoval:^(BOOLremovalSuccessful,NSError*error) {
}];
NSArray *myTodos = [self.store findAllByType:@"todo"];
The source code is available on Github: https://github.com/kaalita/Hoodie-iOS
Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.
Katrin Apel, [email protected]
HOOHoodie is available under the Apache 2.0 license. See the LICENSE file for more info.