This repository was archived by the owner on Jul 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYYModelExample.m
More file actions
67 lines (54 loc) · 2.26 KB
/
YYModelExample.m
File metadata and controls
67 lines (54 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// YYModelExample.m
// YYKitSample
//
// Created by lichuanjun on 2018/9/18.
// Copyright © 2018年 lichuanjun. All rights reserved.
//
#import "YYModelExample.h"
@interface YYModelExample ()
@property (nonatomic, strong) NSMutableArray *titles;
@property (nonatomic, strong) NSMutableArray *classNames;
@end
@implementation YYModelExample
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"YYModel";
self.titles = @[].mutableCopy;
self.classNames = @[].mutableCopy;
[self addCell:@"SimpleModel(简单的数据模型)" class:@"TLSimpleModelVC"];
[self addCell:@"DoubleModel(双模型)" class:@"TLDoubleModelVC"];
[self addCell:@"DifferentJSONKey(键值和属性不同)" class:@"TLDifferentJSONKeyVC"];
[self addCell:@"Container Property(容器模型)" class:@"TLContainerModelVC"];
[self addCell:@"WhiteList&BlackList(黑白名单)" class:@"TLBlacklistAndWhitelistVC"];
[self addCell:@"TimeStamp" class:@"TLTimestampVC"];
[self addCell:@"多样化的数据类型交换" class:@"TLMoreChangeVC"];
[self addCell:@"自定义类数据转换" class:@"TLDefineChangeVC"];
}
- (void)addCell:(NSString *)title class:(NSString *)className {
[self.titles addObject:title];
[self.classNames addObject:className];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _titles.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YYModelExample"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YYModelExample"];
}
cell.textLabel.text = _titles[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *className = self.classNames[indexPath.row];
Class class = NSClassFromString(className);
if (class) {
UIViewController *ctrl = class.new;
ctrl.title = _titles[indexPath.row];
[self.navigationController pushViewController:ctrl animated:YES];
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end