Skip to content

Instantly share code, notes, and snippets.

@subdigital
Created February 21, 2012 18:17
Show Gist options
  • Select an option

  • Save subdigital/1877934 to your computer and use it in GitHub Desktop.

Select an option

Save subdigital/1877934 to your computer and use it in GitHub Desktop.
factories for an inheritance tree
@interface Person : NSObject
@property (copy) NSString *name;
@end
@interface Customer : Person
@property (copy) NSString *status;
@end
[MFFactory defineFactoryForClass:[Person class] withBlock:^(id p){
[p setName:@"foo"];
}];
// this factory would automatically gain the behavior from the Person factory,
// because its class's super class has a factory already defined
[MFFactory defineFactoryForClass:[Customer class] withBlock:^(id c) {
[c setStatus:@"gold"];
}];
// or, more explicitly:
[MFFactory defineFactoryForClass:[Customer class] baseFactory:@"some_custom_factory" withBlock:^(id customer) {
...
}];
@casademora
Copy link
Copy Markdown

casademora commented Feb 21, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment