Skip to content

Instantly share code, notes, and snippets.

@azu
Last active December 15, 2015 15:48
Show Gist options
  • Save azu/5283951 to your computer and use it in GitHub Desktop.
Save azu/5283951 to your computer and use it in GitHub Desktop.
mogenerator --base-class BasedManagedObject
//
// Created by azu on 12/11/19.
//
#import <Foundation/Foundation.h>
@interface BasedManagedObject : NSManagedObject
@property(nonatomic, strong) NSString *identifier;
@end
//
// Created by azu on 12/11/19.
//
#import "BasedManagedObject.h"
@implementation BasedManagedObject {
}
@synthesize identifier = _identifier;
- (void)awakeFromInsert {
[super awakeFromInsert];
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidStr = (__bridge_transfer NSString *) CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease((CFTypeRef) uuid);
self.identifier = uuidStr;
}
@end
mogenerator -m HOGE/HOGE.xcdatamodeld/ -O HOGE/App/Models \
--template-var arc=true \
--base-class BasedManagedObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment