TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Aziz U. Latypov.
Import to your pch file
#import <ALManagedObjectFactory/ALManagedObjectFactory.h>
Use singleton to get a factory
#import <ALManagedObjectFactory/ALManagedObjectFactory+Singleton.h>
// get factory
[ALManagedObjectFactory defaultFactory];
For each entity create a category on ALManagedObjectFactory. Lets say there is a Tag entity, which has a Title. Then you should create category 'ALManagedObjectFactory+CreateTag' and implement:
@implementation ALManagedObjectFactory (CreateTag)
- (Tag*)createTagWithTitle:(NSString*)title
{
Tag *product = (Tag*)[self createObjectForEntityClass:[Tag class]];
// // or you can use
// Tag *product = (Tag*)[self createObjectForEntityName:@"Tag"];
product.title = title;
return product;
}
@end
If you are using the singleton also install ALCoreDataManager and configure it in your AppDelegate before any call to ALManagedObjectFactory.
Aziz U. Latypov, [email protected]
ALManagedObjectFactory is available under the MIT license. See the LICENSE file for more info.