Browse Source

Merge pull request #265 from dlo/master

Use Objective-C 2.0 subscripting
Jonas Budelmann 9 years ago
parent
commit
c6e91f0e93
2 changed files with 8 additions and 8 deletions
  1. 4 4
      Masonry/NSArray+MASAdditions.m
  2. 4 4
      Masonry/NSLayoutConstraint+MASDebugAdditions.m

+ 4 - 4
Masonry/NSArray+MASAdditions.m

@@ -48,7 +48,7 @@
     if (axisType == MASAxisTypeHorizontal) {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
-            MAS_VIEW *v = [self objectAtIndex:i];
+            MAS_VIEW *v = self[i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     make.width.equalTo(prev);
@@ -68,7 +68,7 @@
     else {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
-            MAS_VIEW *v = [self objectAtIndex:i];
+            MAS_VIEW *v = self[i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     make.height.equalTo(prev);
@@ -97,7 +97,7 @@
     if (axisType == MASAxisTypeHorizontal) {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
-            MAS_VIEW *v = [self objectAtIndex:i];
+            MAS_VIEW *v = self[i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
@@ -120,7 +120,7 @@
     else {
         MAS_VIEW *prev;
         for (int i = 0; i < self.count; i++) {
-            MAS_VIEW *v = [self objectAtIndex:i];
+            MAS_VIEW *v = self[i];
             [v mas_makeConstraints:^(MASConstraintMaker *make) {
                 if (prev) {
                     CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));

+ 4 - 4
Masonry/NSLayoutConstraint+MASDebugAdditions.m

@@ -106,16 +106,16 @@
 
     [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
     if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
-        [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]];
+        [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
     }
 
-    [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]];
+    [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
 
     if (self.secondItem) {
         [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
     }
     if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
-        [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]];
+        [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
     }
     
     if (self.multiplier != 1) {
@@ -131,7 +131,7 @@
     }
 
     if (self.priority != MASLayoutPriorityRequired) {
-        [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
+        [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
     }
 
     [description appendString:@">"];