-
Notifications
You must be signed in to change notification settings - Fork 46
/
MITModuleItem.m
50 lines (41 loc) · 1.19 KB
/
MITModuleItem.m
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
#import <objc/runtime.h>
#import "MITModuleItem.h"
@implementation MITModuleItem
- (instancetype)initWithName:(NSString*)name title:(NSString*)title image:(UIImage*)image
{
self = [super init];
if (self) {
_title = [title copy];
_name = [name copy];
_image = image;
_type = MITModulePresentationFullScreen;
}
return self;
}
- (instancetype)initWithName:(NSString*)name title:(NSString*)title image:(UIImage*)image selectedImage:(UIImage*)selectedImage
{
self = [self initWithName:name title:title image:image];
if (self) {
_selectedImage = selectedImage;
}
return self;
}
- (UIImage*)selectedImage
{
if (!_selectedImage) {
return self.image;
} else {
return _selectedImage;
}
}
@end
static void const * MITUIViewController_ModuleItemKey = &MITUIViewController_ModuleItemKey;
@implementation UIViewController (MITModuleItem)
- (void)setModuleItem:(MITModuleItem*)moduleItem
{
objc_setAssociatedObject(self, MITUIViewController_ModuleItemKey, moduleItem, OBJC_ASSOCIATION_RETAIN);
}
- (MITModuleItem*)moduleItem {
return objc_getAssociatedObject(self, MITUIViewController_ModuleItemKey);
}
@end