Authored by Nikolay Tymchenko

Unprefix _equalToWithRelation and _valueOffset

@@ -69,12 +69,12 @@ @@ -69,12 +69,12 @@
69 }; 69 };
70 } 70 }
71 71
72 -#pragma mark - NSLayoutRelation proxies 72 +#pragma mark - NSLayoutRelation proxy
73 73
74 -- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation { 74 +- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
75 return ^id(id attr, NSLayoutRelation relation) { 75 return ^id(id attr, NSLayoutRelation relation) {
76 for (MASConstraint *constraint in self.childConstraints.copy) { 76 for (MASConstraint *constraint in self.childConstraints.copy) {
77 - constraint._equalToWithRelation(attr, relation); 77 + constraint.equalToWithRelation(attr, relation);
78 } 78 }
79 return self; 79 return self;
80 }; 80 };
@@ -35,6 +35,19 @@ @@ -35,6 +35,19 @@
35 @end 35 @end
36 36
37 37
  38 +@interface MASConstraint (Abstract)
  39 +
  40 +/**
  41 + * Sets the constraint relation to given NSLayoutRelation
  42 + * returns a block which accepts one of the following:
  43 + * MASViewAttribute, UIView, NSValue, NSArray
  44 + * see readme for more details.
  45 + */
  46 +- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
  47 +
  48 +@end
  49 +
  50 +
38 @protocol MASConstraintDelegate <NSObject> 51 @protocol MASConstraintDelegate <NSObject>
39 52
40 /** 53 /**
@@ -44,6 +44,11 @@ @@ -44,6 +44,11 @@
44 - (MASConstraint * (^)(CGFloat offset))offset; 44 - (MASConstraint * (^)(CGFloat offset))offset;
45 45
46 /** 46 /**
  47 + * Modifies the NSLayoutConstraint constant based on a value type
  48 + */
  49 +- (MASConstraint * (^)(NSValue *value))valueOffset;
  50 +
  51 +/**
47 * Sets the NSLayoutConstraint multiplier property 52 * Sets the NSLayoutConstraint multiplier property
48 */ 53 */
49 - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 54 - (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
@@ -166,11 +171,11 @@ @@ -166,11 +171,11 @@
166 * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 171 * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
167 * A potential drawback of this is that the unprefixed macros will appear in global scope. 172 * A potential drawback of this is that the unprefixed macros will appear in global scope.
168 */ 173 */
169 -#define mas_equalTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationEqual)  
170 -#define mas_greaterThanOrEqualTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationGreaterThanOrEqual)  
171 -#define mas_lessThanOrEqualTo(...) _equalToWithRelation(MASBoxValue((__VA_ARGS__)), NSLayoutRelationLessThanOrEqual) 174 +#define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__)))
  175 +#define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
  176 +#define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
172 177
173 -#define mas_offset(...) _valueOffset(MASBoxValue((__VA_ARGS__))) 178 +#define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__)))
174 179
175 180
176 #ifdef MAS_SHORTHAND_GLOBALS 181 #ifdef MAS_SHORTHAND_GLOBALS
@@ -187,19 +192,6 @@ @@ -187,19 +192,6 @@
187 @interface MASConstraint (AutoboxingSupport) 192 @interface MASConstraint (AutoboxingSupport)
188 193
189 /** 194 /**
190 - * Modifies the NSLayoutConstraint constant based on a value type  
191 - */  
192 -- (MASConstraint * (^)(id))_valueOffset;  
193 -  
194 -/**  
195 - * Sets the constraint relation to given NSLayoutRelation  
196 - * returns a block which accepts one of the following:  
197 - * MASViewAttribute, UIView, NSValue, NSArray  
198 - * see readme for more details.  
199 - */  
200 -- (MASConstraint * (^)(id attr, NSLayoutRelation relation))_equalToWithRelation;  
201 -  
202 -/**  
203 * Dummy methods to aid autocompletion 195 * Dummy methods to aid autocompletion
204 */ 196 */
205 - (MASConstraint * (^)(id attr))mas_equalTo; 197 - (MASConstraint * (^)(id attr))mas_equalTo;
@@ -26,19 +26,19 @@ @@ -26,19 +26,19 @@
26 26
27 - (MASConstraint * (^)(id))equalTo { 27 - (MASConstraint * (^)(id))equalTo {
28 return ^id(id attribute) { 28 return ^id(id attribute) {
29 - return self._equalToWithRelation(attribute, NSLayoutRelationEqual); 29 + return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
30 }; 30 };
31 } 31 }
32 32
33 - (MASConstraint * (^)(id))greaterThanOrEqualTo { 33 - (MASConstraint * (^)(id))greaterThanOrEqualTo {
34 return ^id(id attribute) { 34 return ^id(id attribute) {
35 - return self._equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 35 + return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
36 }; 36 };
37 } 37 }
38 38
39 - (MASConstraint * (^)(id))lessThanOrEqualTo { 39 - (MASConstraint * (^)(id))lessThanOrEqualTo {
40 return ^id(id attribute) { 40 return ^id(id attribute) {
41 - return self._equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 41 + return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
42 }; 42 };
43 } 43 }
44 44
@@ -95,8 +95,8 @@ @@ -95,8 +95,8 @@
95 }; 95 };
96 } 96 }
97 97
98 -- (MASConstraint * (^)(id))_valueOffset {  
99 - return ^id(id offset) { 98 +- (MASConstraint * (^)(NSValue *value))valueOffset {
  99 + return ^id(NSValue *offset) {
100 NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 100 NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
101 [self setLayoutConstantWithValue:offset]; 101 [self setLayoutConstantWithValue:offset];
102 return self; 102 return self;
@@ -149,7 +149,7 @@ @@ -149,7 +149,7 @@
149 149
150 - (MASConstraint * (^)(MASLayoutPriority priority))priority { methodNotImplemented(); } 150 - (MASConstraint * (^)(MASLayoutPriority priority))priority { methodNotImplemented(); }
151 151
152 -- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation { methodNotImplemented(); } 152 +- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { methodNotImplemented(); }
153 153
154 - (MASConstraint * (^)(id key))key { methodNotImplemented(); } 154 - (MASConstraint * (^)(id key))key { methodNotImplemented(); }
155 155
@@ -126,7 +126,7 @@ @@ -126,7 +126,7 @@
126 126
127 #pragma mark - NSLayoutRelation proxy 127 #pragma mark - NSLayoutRelation proxy
128 128
129 -- (MASConstraint * (^)(id, NSLayoutRelation))_equalToWithRelation { 129 +- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
130 return ^id(id attribute, NSLayoutRelation relation) { 130 return ^id(id attribute, NSLayoutRelation relation) {
131 if ([attribute isKindOfClass:NSArray.class]) { 131 if ([attribute isKindOfClass:NSArray.class]) {
132 NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 132 NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation");