Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ElfSundae/SQLitePersistentObjects
SQLite Persistent Objects for iOS.
https://github.com/ElfSundae/SQLitePersistentObjects
Last synced: about 1 month ago
JSON representation
SQLite Persistent Objects for iOS.
- Host: GitHub
- URL: https://github.com/ElfSundae/SQLitePersistentObjects
- Owner: ElfSundae
- License: mit
- Created: 2013-05-07T04:02:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-25T08:57:10.000Z (almost 9 years ago)
- Last Synced: 2024-10-31T16:12:45.327Z (about 1 month ago)
- Language: Objective-C
- Homepage:
- Size: 1.82 MB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-iOS - SQLitePersistentObjects - Persistent Objects for Cocoa & Cocoa Touch that using SQLite. (Database, ORM, Cache)
README
Introduction
======================Persistent Objects for Cocoa & Cocoa Touch that using SQLite.
This project based on http://code.google.com/p/sqlitepersistentobjects and https://bitbucket.org/gabrielayuso/sqlitepersistentobjects (make it thread safely)
Setup
=====================1. Add `SQLitePersistentObjects.framework` to your Xcode project
2. Link the `libsqlite3.dylib`
3. Add `-ObjC` to your project's settings `Other Linker Flags`
4. `#import ` and subclass `SQLitePersistentObject` for your data modelUsage
======================
**Overview:** http://code.google.com/p/sqlitepersistentobjects/source/browse/trunk/ReadMe.txt1. Declare your data objects inherited from `SQLitePersistentObject`. Every property that's not a collection class (NSDictionary, NSArray, NSSet or mutable variants) will get persisted into a column in the database.
2. Name your properties in the **lower camel case** way. e.g. `productName` will be stored in datebase by named `product_name`.
3. Send `- (void)save;` method to save the data object to database.
4. Query:// get all Product objects from database
NSArray *allObjects = [Product allObjects];
// query with sql, sql starts with 'WHERE'
Product *aProduct = (Product *)[Product findFirstByCriteria:@"WHERE pid = 100"];
NSArray *someProducts = [Product findByCriteria:@"WHERE price > 20.0 LIMIT 0,30"];5. Indexes: just override `+ (NSArray *)indices;` class method.
+ (NSArray *)indices
{
return [NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"pID", nil],
[NSArray arrayWithObjects:@"price", nil]
, nil];
}6. To filter properties that does not need to be saved to the database, just override `+ (NSArray *)transients;` class method.
+ (NSArray *)transients
{
return [NSArray arrayWithObjects:@"isNewlyAdded", nil];
}7. `- (void)deleteObject;`
8. `+ (void)clearCache;`
9. `[SQLiteInstanceManager reset];`
10. `[[SQLiteInstanceManager sharedManager] setDatabaseFilepath:dbPath];`;You may check out the file `SQLitePersistentObject.h` or the SPOSample project for more.