我会建议你有一个单独的解析器类iTemplateParser
然后在其他视图控制器,你可以创建iTemplateParser
对象。
@property (nonatomic, strong) iTemplateParser *templateData;
- (void)viewDidLoad {
NSData *theData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:templateFileName ofType:@"json"]];
self.templateData = [[iTemplateParser alloc] initWithTemplateData:[NSJSONSerialization JSONObjectWithData:theData options:NSJSONReadingMutableContainers error:nil]];
}
现在iTemplateParser
你可以定义许多功能,根据自己的需要。 例如
- (id)initWithTemplateData:(NSDictionary *)iDataDict;
- (CGRect)frameForTableView;
- (UIFont *)fontForTableView;
- (UIColor *)tableBackgroudColor;
等
现在这个方法,你可以在你的ViewController
来电显示的UI组件。
希望这会帮助你。