Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naoty/ntypopulator
A seed data populator for Core Data.
https://github.com/naoty/ntypopulator
Last synced: 2 months ago
JSON representation
A seed data populator for Core Data.
- Host: GitHub
- URL: https://github.com/naoty/ntypopulator
- Owner: naoty
- License: mit
- Created: 2014-04-19T17:34:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-24T02:30:10.000Z (over 10 years ago)
- Last Synced: 2024-10-12T07:44:47.768Z (2 months ago)
- Language: Objective-C
- Size: 168 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# NTYPopulator
[![Version](http://cocoapod-badges.herokuapp.com/v/NTYPopulator/badge.png)](http://cocoadocs.org/docsets/NTYPopulator)
[![Platform](http://cocoapod-badges.herokuapp.com/p/NTYPopulator/badge.png)](http://cocoadocs.org/docsets/NTYPopulator)## Installation
NTYPopulator is available through [CocoaPods](http://cocoapods.org), to install it simply add the following line to your Podfile:
```ruby
platform :ios
pod "NTYPopulator"
```## Usage
```objective-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NTYPopulator new] run];
return YES;
}
````-init` method initializes an instance with the URL of `Model.momd` and `$(CFBundleName).sqlite`. You can also specify these URLs by `-initWithModelURL:sqliteURL:`.
`-run` method populates seed data at `seeds/*.csv` at the application resource bundle. The filename is used to look up an entity name. For example, seed data at `seeds/user.csv` is populated into `User` entity. You can also specify the URL of seed data by `-runWithSeedFileURL:`.
### Efficiency
The populator stores the modification date of each seed files on `NSUserDefaults`. It checks whether each seed files have changes, and then populates only data on changed seed files.
### Safety
By default, when the populator populates data, it will **delete all data and insert again**. So, data inserted after populating will be also deleted.
In order to keep these data, you should add a column `seed_id`. This column values identify which row should be updated, inserted or deleted.
```csv
seed_id,name,age
1,Alice,18
2,Bob,19
3,Charlie,20
```