Welcome to the documentation for the MTLFMDBAdapter! This library provides a convenient and easy-to-use interface for working with SQLite databases in your iOS applications. Whether you are creating a new project or updating an existing one, this adapter will help simplify your database interactions.
Installation
To install MTLFMDBAdapter, simply add the following line to your Podfile:
pod 'MTLFMDBAdapter'
Then, run the following command:
pod install
Usage
The MTLFMDBAdapter extends the capabilities of the Mantle framework, which is a widely-used library for implementing model objects in Objective-C. It seamlessly integrates with Mantle and allows you to persist your model objects in an SQLite database.
Initializing the Adapter
Before you can use the MTLFMDBAdapter, you need to initialize it with the appropriate FMDatabaseQueue:
// Initialize the database queue
FMDatabaseQueue *databaseQueue = [[FMDatabaseQueue alloc] initWithPath:yourDatabasePath];
// Initialize the adapter
MTLFMDBAdapter *adapter = [[MTLFMDBAdapter alloc] initWithDatabaseQueue:databaseQueue];
Saving and Fetching Model Objects
The MTLFMDBAdapter provides convenient methods for saving and fetching model objects:
- Save: To save a model object, simply call the `saveModel:withTransaction:` method on the adapter.
- Fetch: To fetch model objects, use the `fetchModelOfClass:withKey:value:error:` method on the adapter.
// Save a model object
[adapter saveModel:modelObject withTransaction:YES];
// Fetch model objects
NSArray *fetchedObjects = [adapter fetchModelOfClass:[YourModelObject class] withKey:@"propertyName" value:@"propertyValue" error:nil];
Additional Resources
For more information on how to use the MTLFMDBAdapter, check out the official GitHub repository and the CocoaDocs page.
Conclusion
The MTLFMDBAdapter is a powerful library that simplifies SQLite database operations in iOS applications. By leveraging the capabilities of Mantle, it provides an intuitive interface for persisting and retrieving model objects. We hope you find this library useful in your projects!