Skip to content

tonyli508/ObjectStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectStorage

CocoaPods Build Status

ObjectStorage is a framework that make CRUD works on your model entities, you may choose what storage you want e.g. Sqlite, CoreData, plist...

Current Support

  • CoreData
  • Sqlite
  • UserDefaults
  • Keychains
  • File

How to use

Best thing to do is have a look at ObjectStorageTests.

  1. Make your model conform to Model protocol, I suggest you create a base class for that, take a look at MappableModel in ObjectStorageTests folder.
class UserProfile: Model
Most import for CoreData is set up your ModelIdentifier in your model.
public typealias ModelIdentifier = (modelName: String, keys: [String], values: [String?])
modelName is the CoreData model name, keys and values will use for CoreData queries.
  1. Create StorageProviderService instance
let storageProvider = StorageProviderService(coreDataModelFileName: "Model")
  1. Then CRUD your model
let profile = UserProfile(firstName: 'Jiantang', lastName: 'Li')
storageProvider.create(profile)
storageProvider.update(profile)
let read = storageProvider.read(profile)
storageProvider.delete(profile)

CocoaPods

ObjectStorage's already taken, so I use 'LiObjectStorage' instead.

pod 'LiObjectStorage', '~> 0.1.1'

Carthage

github "tonyli508/ObjectStorage", "~> 0.1.1"

TODOs

  • Simplify Model Protocol.
  • More storage support.
  • Add more complex testings.
  • Carthage support.

About

ObjectStorage is a framework written in Swift for CRUD your model entities, you may choose what type of storage you want e.g. Sqlite, CoreData, plist...

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published