Mar*_*ark 5 core-data ios swift ensembles
我想使用来自github的Drew McCormack的Ensembles来缓解我目前的iOS/swift/coredata/iCloud引发的头痛.所有Ensembles示例都在Objective-C中.我在项目中将它作为一个框架,但作为一个周末编码器,我无法推断如何从ObjC示例代码中使用它.
有没有人看过使用swift的合奏方法?
添加:我有它作为一个框架,但我如何设置它并让它开始Leching?Obj-C的方式是
//SetupEnsemble
cloudFileSystem=[[CDEICloudFileSystemalloc] initWithUbiquityContainerIdentifier:@"container"];
ensemble=[[CDEPersistentStoreEnsemblealloc]initWithEnsembleIdentifier:@"MainStore" persistentStoreURL:storeURL
managedObjectModelURL:modelURL
cloudFileSystem:cloudFileSystem]; ensemble.delegate=self;
Run Code Online (Sandbox Code Playgroud)
然后是利奇
if(!ensemble.isLeeched){
[ensemble leechPersistentStoreWithCompletion:^(NSError *error) {
if (error) NSLog(@"Could not leech to ensemble: %@", error); }];}
Run Code Online (Sandbox Code Playgroud)
小智 2
以下步骤描述了如何将带有 iCloud + Dropbox 文件系统的集成添加到项目中:
将“Podfile”添加到您的项目中,其中包含以下内容:
target :YOUR_TARGET_NAME do
platform :ios, '7.0'
pod "Ensembles", :git => 'https://github.com/drewmccormack/ensembles.git'
pod "Ensembles/Dropbox", :git => 'https://github.com/drewmccormack/ensembles.git'
link_with 'YOUR_TARGET_NAME'
end
Run Code Online (Sandbox Code Playgroud)
从终端运行“pod install”
创建ObjC 桥接头
添加 Ensembles(以及其他框架到桥接标头):
#import <Foundation/Foundation.h>
#import <Ensembles/Ensembles.h>
#import "DropboxSDK.h"
#import "CDEDropboxCloudFileSystem.h"
Run Code Online (Sandbox Code Playgroud)
快乐编码:
var ensemble:CDEPersistentStoreEnsemble?
var ensembleFileSystem:CDECloudFileSystem?
ensembleFileSystem = CDEICloudFileSystem(
ubiquityContainerIdentifier: "SOME_CONTAINER",
relativePathToRootInContainer: "STORE_ROOT_PATH"
)
ensemble = CDEPersistentStoreEnsemble(
ensembleIdentifier: "IDENTIFIER",
persistentStoreURL: "STORE_URL",
persistentStoreOptions:nil,
managedObjectModelURL:"MOM_URL",
cloudFileSystem:ensembleFileSystem,
localDataRootDirectoryURL:"DATA_ROOT_URL"
)
e.leechPersistentStoreWithCompletion({ (error:NSError?) -> Void in
// check for error, etc...
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
727 次 |
| 最近记录: |