ALManagedObjectFactory 0.2.1

ALManagedObjectFactory 0.2.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Aziz U. Latypov.



  • By
  • aziz u. latypov

Usage

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

Requirements

If you are using the singleton also install ALCoreDataManager and configure it in your AppDelegate before any call to ALManagedObjectFactory.

Installation

Author

Aziz U. Latypov, [email protected]

License

ALManagedObjectFactory is available under the MIT license. See the LICENSE file for more info.