templates/Keys.m.erb in cocoapods-keys-2.1.0 vs templates/Keys.m.erb in cocoapods-keys-2.2.0

- old
+ new

@@ -2,54 +2,42 @@ // Generated by CocoaPods-Keys // on <%= @time.strftime("%d/%m/%Y") %> // For more information see https://github.com/orta/cocoapods-keys // -#import <objc/runtime.h> #import <Foundation/NSDictionary.h> #import "<%= @name %>.h" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wincomplete-implementation" +@interface <%= @name %> () -@implementation <%= @name %> -<% @keys.each do |key, value| %> - @dynamic <%= key %>;<% end %> +<% @keys.each do |key, value| %>@property (nonatomic, copy) NSString *<%= key %>; +<% end %> -#pragma clang diagnostic pop +@end -+ (BOOL)resolveInstanceMethod:(SEL)name -{ - NSString *key = NSStringFromSelector(name); - NSString * (*implementation)(<%= name %> *, SEL) = NULL; -<% @keys.each do |key, value| %> - if ([key isEqualToString:@"<%= key %>"]) { - implementation = _podKeys<%= Digest::MD5.hexdigest(key) %>; - } -<% end %> - if (!implementation) { - return [super resolveInstanceMethod:name]; - } +@implementation <%= @name %> - return class_addMethod([self class], name, (IMP)implementation, "@@:"); -} -<% @keys.each do |key, value| %> -static NSString *_podKeys<%= Digest::MD5.hexdigest(key) %>(<%= name %> *self, SEL _cmd) +- (instancetype)init { - <% if @indexed_keys.length > 0 %> - <% if @indexed_keys[key].length > 0 %> - char cString[<%= @indexed_keys[key].length + 1 %>] = { <%= key_data_arrays[key] %>, '\0' }; - <% else %> - char cString[1] = { '\0' }; + if (!(self = [super init])) { return nil; } + + <% @keys.each do |key, value| %> + char <%= key %>CString[<%= @indexed_keys[key].length + 1 %>] = { <%= key_data_arrays[key] %>, '\0' }; + _<%= key %> = <% if @indexed_keys.length > 0 %> + <% if @indexed_keys[key].length > 0 %> + [NSString stringWithCString:<%= key %>CString encoding:NSUTF8StringEncoding]; + <% else %> + @""; + <% end %> + <% else %> + @""; + <% end %> <% end %> - return [NSString stringWithCString:cString encoding:NSUTF8StringEncoding]; - <% else %> - return @""; - <% end %> + + return self; } -<% end %> -static char <%= name %>Data[<%= @data_length %>] = "<%= @data.gsub('\\', '\\\\\\').gsub('"', '\\"') if @data %>"; +static NSString *<%= name %>Data = @"<%= @data.gsub('\\', '\\\\\\').gsub('"', '\\"') if @data %>"; - (NSString *)description { return [@{ <%- @keys.each do |key, value| -%>