Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I create a template to generate swift-like structure objects for ObjC? #157

Closed
appleios opened this issue Sep 16, 2016 · 1 comment
Closed

Comments

@appleios
Copy link

appleios commented Sep 16, 2016

In swift we can create structs:

struct Person {
  var name: String
  var familyName: String
}

and get an initilizer for free:

let adam = Person(name: "Adam", familyName: "Smith")

In objc we have to create a class of kind:

@interface Person : NSObject
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *familyName;
- (instancetype)initWithName:(NSString*)name familyName:(NSString*)familyName;
@end
@implementation Person
- (instancetype)initWithName:(NSString*)name familyName:(NSString*)familyName;
{
  self = [super init];
  if(self) {
    _name =  name;
    _familyName = familyName;
  }
}
@end

Is it possible to create a template for generamba for generation of this kind of swift-struct like classes for ObjC, for example, like this:

generamba gen objcstruct Person name:String familyName:String
@appleios appleios changed the title Can I create a template to generate swift-like structure objects in ObjC Can I create a template to generate swift-like structure objects for ObjC? Sep 16, 2016
@etolstoy
Copy link
Member

@appleios Yes, it's possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants