https://github.com/tonyli508/objectstorage
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...
https://github.com/tonyli508/objectstorage
coredata modeling objectstorage
Last synced: 4 months ago
JSON representation
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...
- Host: GitHub
- URL: https://github.com/tonyli508/objectstorage
- Owner: tonyli508
- License: mit
- Created: 2016-09-04T13:47:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T21:00:20.000Z (over 9 years ago)
- Last Synced: 2025-10-23T11:55:28.502Z (4 months ago)
- Topics: coredata, modeling, objectstorage
- Language: Swift
- Homepage:
- Size: 70.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ObjectStorage
[](https://github.com/tonyli508/ObjectStorage.git)
[](https://travis-ci.org/tonyli508/ObjectStorage)
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
- [x] 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.
```swift
class UserProfile: Model
```
Most import for CoreData is set up your ModelIdentifier in your model.
```swift
public typealias ModelIdentifier = (modelName: String, keys: [String], values: [String?])
```
modelName is the CoreData model name, keys and values will use for CoreData queries.
2. Create StorageProviderService instance
```swift
let storageProvider = StorageProviderService(coreDataModelFileName: "Model")
```
3. Then CRUD your model
```swift
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.
```ruby
pod 'LiObjectStorage', '~> 0.1.1'
```
## Carthage
```ruby
github "tonyli508/ObjectStorage", "~> 0.1.1"
```
## TODOs
- Simplify Model Protocol.
- More storage support.
- Add more complex testings.
- Carthage support.