测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可 | Apache 2 |
版本最新版本 | 2014年12月 |
由 Katrin Apel 维护。
依赖 | |
AFNetworking | ~> 2.0 |
FMDB | ~> 2.3 |
Hoodie-iOS 是一个库,它连接到 Hoodie 后端 API。有关 Hoodie 的更多信息,请参阅 http://hood.ie/(作为本地存储,使用的是功能强大的 Couchbase Lite 框架,它还负责处理服务器与服务器之间的复制)。
它目前还不支持完整的 API 和功能(请参阅问题部分以了解还缺少什么)。目前支持的功能
要运行示例项目;首先从 repo 克隆项目,然后从 Example 目录运行 pod install
。
然后安装 Hoodie Server 并创建新的 Hoodie 应用程序,这将作为您 iOS 应用的后端(有关说明,请参阅 http://hood.ie/#installation)。
要开始使用 Hoodie-iOS,首先安装 Hoodie Server 并创建并启动新的 Hoodie 应用程序(请参阅 http://hood.ie/#installation 以获取说明)。
#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:@"https://: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) {
}];
如果用户成功登录,Hoodie 将在启动时自动在此设备上登录,直到用户明确登出为止。
[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) {
}];
当前,Hoodie商店仅接受NSDictionaries作为存储对象。
由Hoodie商店自动设置的保留键包括:_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"];
源代码可在Github上获取:https://github.com/kaalita/Hoodie-iOS
欢迎任何人和每个人 contribute。请花一点时间查阅贡献指南。
Katrin Apel, [email protected]
HOOHoodie在Apache 2.0许可证下可用。查看LICENSE文件获取更多信息。