This repository was archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from NSElvis/version-2-0-0
ANDYDataManager 2.0
- Loading branch information
Showing
13 changed files
with
211 additions
and
183 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@import Foundation; | ||
@import CoreData; | ||
|
||
|
||
typedef NS_ENUM(NSInteger, ANDYDataStoreType) { | ||
ANDYDataInMemoryStoreType = 0, | ||
ANDYDataSQLiteStoreType | ||
}; | ||
|
||
@interface ANDYDataStack : NSObject | ||
|
||
/*! | ||
* @discussion Creates an instance of ANDYDataStack with SQLiteStoreType using the app's name as a Core Data model name. | ||
* @return An instance of @c ANDYDataStack or @c nil if the model is not found. | ||
*/ | ||
- (instancetype)init; | ||
|
||
/*! | ||
* @discussion Creates an instance of ANDYDataStack with SQLiteStoreType. | ||
* @param modelName The name of the Core Data model. | ||
* @return An instance of @c ANDYDataStack or @c nil if the model is not found. | ||
*/ | ||
- (instancetype)initWithModelName:(NSString *)modelName; | ||
|
||
/*! | ||
* @discussion Creates an instance of ANDYDataStack with SQLiteStoreType. | ||
* @param modelName The name of the Core Data model. | ||
* @param bundle The bundle where the Core Data model is located. | ||
* @param storeType The store type, either @c SQLite or @c InMemory. | ||
* @return An instance of @c ANDYDataStack or @c nil if the model is not found. | ||
*/ | ||
- (instancetype)initWithModelName:(NSString *)modelName | ||
bundle:(NSBundle *)bundle | ||
storyType:(ANDYDataStoreType)storeType NS_DESIGNATED_INITIALIZER; | ||
|
||
/*! | ||
* Provides a NSManagedObjectContext appropriate for use on the main | ||
* thread. | ||
*/ | ||
@property (strong, nonatomic, readonly) NSManagedObjectContext *mainThreadContext; | ||
|
||
/*! | ||
* Provides a safe way to perform an operation in a background | ||
* operation by using a context. | ||
*/ | ||
- (void)performInBackgroundContext:(void (^)(NSManagedObjectContext *context))operation; | ||
|
||
/*! | ||
* Saves current state of mainContext into the database. | ||
*/ | ||
- (void)persistContext; | ||
|
||
/*! | ||
* Destroys state of ANDYDataStack. | ||
*/ | ||
- (void)destroy; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.