Giter Club home page Giter Club logo

contentstack-ios-persistence's Introduction

Contentstack

Contentstack iOS Persistence Library

Contentstack provides iOS Persistence Library that lets your application store data on the device's local storage. This helps you build apps that can work offline too. Given below is a detailed guide and helpful resources to get started with our iOS Persistence Library.

Prerequisites

  • Latest Xcode and Mac OS X

Setup and Initialize library

You can use the iOS Persistence Library with CoreData and Realm databases. Let's understand how to set these up for your project.

For CoreData

To set up this library for CoreData, follow the steps given below.

Setup using CocoaPods

  1. Add the following line to your Podfile:
pod 'ContentstackPersistenceCoreData'
  1. Run pod install, and you should now have the latest version of the library.

Import header/module

#import <ContentstackPersistenceCoreData/ContentstackPersistenceCoreData.h>;

You can also import as a Module:

//Objc

@import ContentstackPersistenceCoreData

//Swift

import ContentstackPersistenceCoreData

Initialize the library

To start using the library in your application, you will need to initialize it by providing your stack details:

//Objc
Config *config = [[Config alloc] init];
config.host = @"customcontentstack.io";
Stack *stack = [Contentstack stackWithAPIKey:<APIKey> accessToken:<AccessToken> environmentName:<EnvironmentName> config:config];
CoreDataStore *coreDataStore = [[CoreDataStore alloc] initWithContenxt: <NSManageObjectContext>];
SyncManager *syncManager = [[SyncManager alloc] initWithStack:stack persistance:coreDataStore]
[syncManager sync:{ (percentageComplete, isSyncCompleted, error) in

}];

//Swift

let config = Config()
config.host = @"customcontentstack.io";
let stack : Stack = Contentstack.stack(withAPIKey: <APIKey>, accessToken: <AccessToken>, environmentName: <EnvironmentName>, config:config)
var coreDataStore = CoreDataStore(contenxt: <NSManageObjectContext>)
var syncManager : SyncManager = SyncManager(stack: stack, persistance: coreDataStore)
syncManager.sync({ (percentage, isSynccompleted, error) in

})

For Realm

To set up this library for Realm, follow the steps given below.

Setup using CocoaPods

  1. Add the following line to your Podfile:
pod 'ContentstackPersistenceRealm'
  1. Run pod install, and you should now have the latest version of the library.

Import header/module

You can import header file in Objective-C project as:

#import <ContentstackPersistenceRealm/ContentstackPersistenceRealm.h>;

You can also import as a Module:

//Objc

@import ContentstackPersistenceRealm

//Swift

import ContentstackPersistenceRealm

Initialize the library

To start using the library in your application, you will need to initialize it by providing the stack details:

//Objc
Config *config = [[Config alloc] init];
config.host = @"customcontentstack.io";
Stack *stack = [Contentstack stackWithAPIKey:<APIKey> accessToken:<AccessToken> environmentName:<EnvironmentName> config:config];
RealmStore *realmStore = [[RealmStore alloc] initWithRealm:[[RLMRealm alloc] init]];
SyncManager *syncManager = [[SyncManager alloc] initWithStack:stack persistance:realmStore]
[syncManager sync:{ (percentageComplete, isSyncCompleted, error) in

}];

//Swift

let config = Config()
config.host = @"customcontentstack.io";
let stack : Stack = Contentstack.stack(withAPIKey: <APIKey>, accessToken: <AccessToken>, environmentName: <EnvironmentName>, config:config)
var realmStore = RealmStore(realm: RLMRealm())
var syncManager : SyncManager = SyncManager(stack: stack, persistance: realmStore)
syncManager.sync({ (percentage, isSynccompleted, error) in

})

We have created an example app using iOS Persistence Library that stores data on the device's local storage. Read the tutorial to get started with the example app.

Helpful Links

contentstack-ios-persistence's People

Contributors

uttamukkoji avatar

Watchers

Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.