kuzzlesdk 1.0.0

kuzzlesdk 1.0.0

测试已测试
Lang语言 SwiftSwift
许可 Apache 2
发布最后发布2016 年 6 月
SPM支持 SPM

Maciej Madaj 维护。



kuzzlesdk 1.0.0

  • Maciej Madaj 和 kuzzle.io

官方 Kuzzle iOS SDK

此 SDK 版本需要 Kuzzle v1.0.0-beta.1 或更高版本。

关于 Kuzzle

对于 UI 和链接对象开发者,Kuzzle 是一个开源解决方案,用于处理所有数据管理(CRUD、实时存储、搜索、高级功能等)。

您可以在 Github 上访问 Kuzzle 仓库

SDK 文档

从 2016 年 6 月 1 日起,iOS (Swift/Objective-C)完整 SDK 文档可在 此处 获取。

由于使用了动态框架,我们支持 iOS 8+。SDK 以 Swift 2.x 编写,并支持 Objective-C。

安装

用法

导入

Swift

import kuzzlesdk

Objective-C

#import "kuzzlesdkObjC/kuzzlesdkObjC-Swift.h"
// or when using cocapods
#import <kuzzlesdkObjC/kuzzlesdkObjC-Swift.h>

连接到 Kuzzle

Swift

let kuzzle = try Kuzzle(url: "localhost", options: options, connectionCallback: {
    result in
    switch result {
        case let .onError(error):
            // handle error
        case let .onSuccess(success):
            // handle success
            // e.g. create document
            let dataCollection = kuzzle.dataCollectionFactory(collectionName: "test", index: "index")
            let document = KuzzleDocument(dataCollection).
            try! document.setContent(content: ["foo": "bar"]).apply()
        break
    }
})

Objective-C

NSError* error = nil;
kuzzle = [[Kuzzle alloc] initWithUrl: @"localhost" error: &error connectionCallback:^(id onSuccess, NSError* onError) {
    if(onError) {
        // handle error
        return;
    }
    // handler success
    // e.g. create document
    // use line below to immedietaly access Kuzzle after successful connection
    __weak Kuzzle* weakKuzzle = kuzzle;
    NSError* error = nil;
    KuzzleDataCollection* dataCollection = [weakKuzzle dataCollectionFactoryWithCollectionName: @"test" error: &error];
    KuzzleDocument* document = [[KuzzleDocument alloc] initWithCollection: dataCollection];
    // calling save will store document on remote kuzzle instance
    [[document setContentWithContent: @{@"foo": @"bar"}] saveAndReturnError: &error];
}];

许可

Kuzzle 在 Apache 2 许可 下发布。