Skip to content
Snippets Groups Projects
Commit 6d19724a authored by Nate Kibler's avatar Nate Kibler
Browse files

Adds class factory method to generated ProtoService classes

parent d09a28e4
No related branches found
No related tags found
No related merge requests found
......@@ -203,6 +203,7 @@ void PrintMethodImplementations(Printer *printer,
printer.Print(
"- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n");
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n");
printer.Print("@end\n");
}
return output;
......@@ -239,6 +240,10 @@ void PrintMethodImplementations(Printer *printer,
printer.Print(" packageName:(NSString *)packageName\n");
printer.Print(" serviceName:(NSString *)serviceName {\n");
printer.Print(" return [self initWithHost:host];\n");
printer.Print("}\n\n");
printer.Print("// Class factory method\n");
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host {\n");
printer.Print(" return [[self alloc] initWithHost:host];\n");
printer.Print("}\n\n\n");
for (int i = 0; i < service->method_count(); i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment