@@ -36,72 +36,70 @@ @implementation CALayer (DynamicProperties)
36
36
+ (void ) _dynamicallyCreateProperty : (objc_property_t )property
37
37
{
38
38
39
- NSString * name = [NSString stringWithCString: property_getName (property)
40
- encoding: NSASCIIStringEncoding];
41
-
42
- NSDictionary * attributes = [self _dynamicPropertyProcessAttributes: property];
43
-
44
- // create the method names
45
- NSString * getterName = [attributes valueForKey: @" getter" ];
46
-
47
- if (getterName == nil )
48
- {
49
- getterName = name;
50
- }
51
-
52
- NSString * setterName = [attributes valueForKey: @" setter" ];
53
-
54
- if (setterName == nil )
55
- {
56
- setterName = [NSString stringWithFormat: @" set%@%@ :" ,
57
- [[name substringToIndex: 1 ] uppercaseString ],
58
- [name substringFromIndex: 1 ]];
59
- }
60
-
61
-
62
- // Set the types
63
- NSString * type = [attributes valueForKey: @" type" ];
64
- NSString * getterTypes = [NSString stringWithFormat: @" %@ @:" , type];
65
- NSString * setterTypes = [NSString stringWithFormat: @" v@:%@ " , type];
66
-
67
- NSString * key = [NSString stringWithFormat: @" dynamicproperty_%@ _%@ " ,
68
- NSStringFromClass ([self class ]),
69
- name];
70
-
71
- IMP getter = [self _getterForKey: key type: type];
72
- IMP setter = [self _setterForKey: key type: type];
73
-
74
- // Add getter
75
- BOOL success;
76
- success = class_addMethod ([self class ],
77
- NSSelectorFromString (getterName),
78
- getter,
79
- [getterTypes cStringUsingEncoding: NSASCIIStringEncoding]);
39
+ NSString * name = [NSString stringWithCString: property_getName (property)
40
+ encoding: NSASCIIStringEncoding];
41
+
42
+ NSDictionary * attributes = [self _dynamicPropertyProcessAttributes: property];
43
+
44
+ // create the method names
45
+ NSString * getterName = [attributes valueForKey: @" getter" ];
46
+ if (getterName == nil )
47
+ {
48
+ getterName = name;
49
+ }
50
+
51
+ NSString * setterName = [attributes valueForKey: @" setter" ];
52
+
53
+ if (setterName == nil )
54
+ {
55
+ setterName = [NSString stringWithFormat: @" set%@%@ :" ,
56
+ [[name substringToIndex: 1 ] uppercaseString ],
57
+ [name substringFromIndex: 1 ]];
58
+ }
80
59
81
- if (!success)
82
- {
83
- [NSException raise :NSGenericException
84
- format: @" Could not add method %@ " , getterName];
85
-
86
- }
87
60
88
- // Add setter
89
- success = class_addMethod ([self class ],
90
- NSSelectorFromString (setterName),
91
- setter,
92
- [setterTypes cStringUsingEncoding: NSASCIIStringEncoding]);
61
+ // Set the types
62
+ NSString * type = [attributes valueForKey: @" type" ];
63
+ NSString * getterTypes = [NSString stringWithFormat: @" %@ @:" , type];
64
+ NSString * setterTypes = [NSString stringWithFormat: @" v@:%@ " , type];
93
65
94
- if (!success)
95
- {
96
- [NSException raise :NSGenericException
97
- format: @" Could not add method %@ " , setterName];
66
+ NSString * key = [NSString stringWithFormat: @" dynamicproperty_%@ _%@ " ,
67
+ NSStringFromClass ([self class ]),
68
+ name];
98
69
99
- }
70
+ IMP getter = [self _getterForKey: key type: type];
71
+ IMP setter = [self _setterForKey: key type: type];
72
+
73
+ // Add getter
74
+ BOOL success;
75
+ success = class_addMethod ([self class ],
76
+ NSSelectorFromString (getterName),
77
+ getter,
78
+ [getterTypes cStringUsingEncoding: NSASCIIStringEncoding]);
79
+
80
+ if (!success)
81
+ {
82
+ [NSException raise : NSGenericException
83
+ format: @" Could not add method %@ " , getterName];
84
+ }
85
+
86
+ // Add setter
87
+ success = class_addMethod ([self class ],
88
+ NSSelectorFromString (setterName),
89
+ setter,
90
+ [setterTypes cStringUsingEncoding: NSASCIIStringEncoding]);
100
91
92
+ if (!success)
93
+ {
94
+ [NSException raise : NSGenericException
95
+ format: @" Could not add method %@ " , setterName];
96
+ }
97
+
101
98
}
102
99
103
100
104
- + (NSDictionary *) _dynamicPropertyProcessAttributes : (objc_property_t )property {
101
+ + (NSDictionary *) _dynamicPropertyProcessAttributes : (objc_property_t )property
102
+ {
105
103
106
104
NSString * attributes = [NSString stringWithCString: property_getAttributes (property)
107
105
encoding: NSASCIIStringEncoding];
0 commit comments