forked from opa334/AltList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSSpecifier+AltList.m
86 lines (81 loc) · 1.63 KB
/
PSSpecifier+AltList.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#import <Foundation/Foundation.h>
@interface PSSpecifier : NSObject
{
@public
id target;
SEL getter;
SEL setter;
}
- (BOOL)hasValidGetter;
- (id)performGetter;
- (BOOL)hasValidSetter;
- (void)performSetterWithValue:(id)value;
@end
#import "PSSpecifier+AltList.h"
@implementation PSSpecifier (AltList)
- (BOOL)atl_hasValidGetter
{
if([self respondsToSelector:@selector(hasValidGetter)])
{
return [self hasValidGetter];
}
else
{
if(getter && target)
{
return [target respondsToSelector:getter];
}
else
{
return NO;
}
}
}
- (id)atl_performGetter
{
if([self respondsToSelector:@selector(performGetter)])
{
return [self performGetter];
}
else
{
if([self atl_hasValidGetter])
{
return [((id (*)(id, SEL, id))[target methodForSelector:getter])(target, getter, self) mutableCopy];
}
return nil;
}
}
- (BOOL)atl_hasValidSetter
{
if([self respondsToSelector:@selector(hasValidSetter)])
{
return [self hasValidSetter];
}
else
{
if(setter && target)
{
return [target respondsToSelector:setter];
}
else
{
return NO;
}
}
}
- (void)atl_performSetterWithValue:(id)value
{
if([self respondsToSelector:@selector(performSetterWithValue:)])
{
[self performSetterWithValue:value];
}
else
{
if([self atl_hasValidSetter])
{
((void (*)(id, SEL, id, id))[target methodForSelector:setter])(target, setter, value, self);
}
}
}
@end