Authored by Jonas Budelmann

Merge pull request #214 from CraigSiemens/layout-guides

Layout guides and iOS 9 support
Showing 100 changed files with 247 additions and 143 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
38 114413081924B6EE008E702E /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; }; 38 114413081924B6EE008E702E /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
39 27A27D441A6CF0C400D34F52 /* MASExampleAspectFitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleAspectFitView.h; sourceTree = "<group>"; }; 39 27A27D441A6CF0C400D34F52 /* MASExampleAspectFitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleAspectFitView.h; sourceTree = "<group>"; };
40 27A27D451A6CF0C400D34F52 /* MASExampleAspectFitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleAspectFitView.m; sourceTree = "<group>"; }; 40 27A27D451A6CF0C400D34F52 /* MASExampleAspectFitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleAspectFitView.m; sourceTree = "<group>"; };
  41 + 321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples.release.xcconfig"; sourceTree = "<group>"; };
41 3C02224819D0C4EC00507321 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; 42 3C02224819D0C4EC00507321 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
42 3DB1CAD3184538E200E91FC5 /* MASExampleArrayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleArrayView.h; sourceTree = "<group>"; }; 43 3DB1CAD3184538E200E91FC5 /* MASExampleArrayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleArrayView.h; sourceTree = "<group>"; };
43 3DB1CAD4184538E200E91FC5 /* MASExampleArrayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleArrayView.m; sourceTree = "<group>"; }; 44 3DB1CAD4184538E200E91FC5 /* MASExampleArrayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleArrayView.m; sourceTree = "<group>"; };
@@ -45,7 +46,7 @@ @@ -45,7 +46,7 @@
45 44C0E6AE1A9B9C55003C70CF /* MASExampleMarginView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleMarginView.m; sourceTree = "<group>"; }; 46 44C0E6AE1A9B9C55003C70CF /* MASExampleMarginView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleMarginView.m; sourceTree = "<group>"; };
46 4BEB55B41957394E008C862B /* MASExampleRemakeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleRemakeView.h; sourceTree = "<group>"; }; 47 4BEB55B41957394E008C862B /* MASExampleRemakeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleRemakeView.h; sourceTree = "<group>"; };
47 4BEB55B51957394E008C862B /* MASExampleRemakeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleRemakeView.m; sourceTree = "<group>"; }; 48 4BEB55B51957394E008C862B /* MASExampleRemakeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleRemakeView.m; sourceTree = "<group>"; };
48 - B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.xcconfig"; path = "../Pods/Pods-Masonry iOS Examples.xcconfig"; sourceTree = "<group>"; }; 49 + 50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples.debug.xcconfig"; sourceTree = "<group>"; };
49 BDC1B8303EED42A2B01B94B1 /* libPods-Masonry iOS Examples.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Masonry iOS Examples.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 50 BDC1B8303EED42A2B01B94B1 /* libPods-Masonry iOS Examples.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Masonry iOS Examples.a"; sourceTree = BUILT_PRODUCTS_DIR; };
50 DD175E68182639FB0099129A /* MASExampleUpdateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleUpdateView.h; sourceTree = "<group>"; }; 51 DD175E68182639FB0099129A /* MASExampleUpdateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleUpdateView.h; sourceTree = "<group>"; };
51 DD175E69182639FB0099129A /* MASExampleUpdateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleUpdateView.m; sourceTree = "<group>"; }; 52 DD175E69182639FB0099129A /* MASExampleUpdateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleUpdateView.m; sourceTree = "<group>"; };
@@ -105,7 +106,7 @@ @@ -105,7 +106,7 @@
105 DD52F230179CAD57005CD195 /* Masonry iOS Examples */, 106 DD52F230179CAD57005CD195 /* Masonry iOS Examples */,
106 DD52F229179CAD57005CD195 /* Frameworks */, 107 DD52F229179CAD57005CD195 /* Frameworks */,
107 DD52F228179CAD57005CD195 /* Products */, 108 DD52F228179CAD57005CD195 /* Products */,
108 - B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */, 109 + DF14AF6879B23556F891E1F7 /* Pods */,
109 ); 110 );
110 sourceTree = "<group>"; 111 sourceTree = "<group>";
111 }; 112 };
@@ -198,6 +199,15 @@ @@ -198,6 +199,15 @@
198 name = Controllers; 199 name = Controllers;
199 sourceTree = "<group>"; 200 sourceTree = "<group>";
200 }; 201 };
  202 + DF14AF6879B23556F891E1F7 /* Pods */ = {
  203 + isa = PBXGroup;
  204 + children = (
  205 + 50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */,
  206 + 321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */,
  207 + );
  208 + name = Pods;
  209 + sourceTree = "<group>";
  210 + };
201 /* End PBXGroup section */ 211 /* End PBXGroup section */
202 212
203 /* Begin PBXNativeTarget section */ 213 /* Begin PBXNativeTarget section */
@@ -273,7 +283,7 @@ @@ -273,7 +283,7 @@
273 ); 283 );
274 runOnlyForDeploymentPostprocessing = 0; 284 runOnlyForDeploymentPostprocessing = 0;
275 shellPath = /bin/sh; 285 shellPath = /bin/sh;
276 - shellScript = "\"${SRCROOT}/../Pods/Pods-Masonry iOS Examples-resources.sh\"\n"; 286 + shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples-resources.sh\"\n";
277 showEnvVarsInLog = 0; 287 showEnvVarsInLog = 0;
278 }; 288 };
279 621F6A1FCAEF44F880874959 /* Check Pods Manifest.lock */ = { 289 621F6A1FCAEF44F880874959 /* Check Pods Manifest.lock */ = {
@@ -393,7 +403,7 @@ @@ -393,7 +403,7 @@
393 }; 403 };
394 DD52F245179CAD57005CD195 /* Debug */ = { 404 DD52F245179CAD57005CD195 /* Debug */ = {
395 isa = XCBuildConfiguration; 405 isa = XCBuildConfiguration;
396 - baseConfigurationReference = B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */; 406 + baseConfigurationReference = 50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */;
397 buildSettings = { 407 buildSettings = {
398 ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 408 ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
399 GCC_PRECOMPILE_PREFIX_HEADER = YES; 409 GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -406,7 +416,7 @@ @@ -406,7 +416,7 @@
406 }; 416 };
407 DD52F246179CAD57005CD195 /* Release */ = { 417 DD52F246179CAD57005CD195 /* Release */ = {
408 isa = XCBuildConfiguration; 418 isa = XCBuildConfiguration;
409 - baseConfigurationReference = B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */; 419 + baseConfigurationReference = 321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */;
410 buildSettings = { 420 buildSettings = {
411 ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 421 ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
412 GCC_PRECOMPILE_PREFIX_HEADER = YES; 422 GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
14 buildForAnalyzing = "YES"> 14 buildForAnalyzing = "YES">
15 <BuildableReference 15 <BuildableReference
16 BuildableIdentifier = "primary" 16 BuildableIdentifier = "primary"
17 - BlueprintIdentifier = "DD52F1A9179CA93B005CD195"  
18 - BuildableName = "libMasonry.a" 17 + BlueprintIdentifier = "3AED05B61AD59FD40053CC65"
  18 + BuildableName = "Masonry.framework"
19 BlueprintName = "Masonry iOS" 19 BlueprintName = "Masonry iOS"
20 ReferencedContainer = "container:../Masonry.xcodeproj"> 20 ReferencedContainer = "container:../Masonry.xcodeproj">
21 </BuildableReference> 21 </BuildableReference>
@@ -62,7 +62,8 @@ @@ -62,7 +62,8 @@
62 ignoresPersistentStateOnLaunch = "NO" 62 ignoresPersistentStateOnLaunch = "NO"
63 debugDocumentVersioning = "YES" 63 debugDocumentVersioning = "YES"
64 allowLocationSimulation = "YES"> 64 allowLocationSimulation = "YES">
65 - <BuildableProductRunnable> 65 + <BuildableProductRunnable
  66 + runnableDebuggingMode = "0">
66 <BuildableReference 67 <BuildableReference
67 BuildableIdentifier = "primary" 68 BuildableIdentifier = "primary"
68 BlueprintIdentifier = "DD52F226179CAD57005CD195" 69 BlueprintIdentifier = "DD52F226179CAD57005CD195"
@@ -80,7 +81,8 @@ @@ -80,7 +81,8 @@
80 useCustomWorkingDirectory = "NO" 81 useCustomWorkingDirectory = "NO"
81 buildConfiguration = "Release" 82 buildConfiguration = "Release"
82 debugDocumentVersioning = "YES"> 83 debugDocumentVersioning = "YES">
83 - <BuildableProductRunnable> 84 + <BuildableProductRunnable
  85 + runnableDebuggingMode = "0">
84 <BuildableReference 86 <BuildableReference
85 BuildableIdentifier = "primary" 87 BuildableIdentifier = "primary"
86 BlueprintIdentifier = "DD52F226179CAD57005CD195" 88 BlueprintIdentifier = "DD52F226179CAD57005CD195"
@@ -34,26 +34,34 @@ @@ -34,26 +34,34 @@
34 topView.layer.borderWidth = 2; 34 topView.layer.borderWidth = 2;
35 [self.view addSubview:topView]; 35 [self.view addSubview:topView];
36 36
  37 + UIView *topSubview = UIView.new;
  38 + topSubview.backgroundColor = UIColor.blueColor;
  39 + topSubview.layer.borderColor = UIColor.blackColor.CGColor;
  40 + topSubview.layer.borderWidth = 2;
  41 + [topView addSubview:topSubview];
  42 +
37 UIView *bottomView = UIView.new; 43 UIView *bottomView = UIView.new;
38 bottomView.backgroundColor = UIColor.redColor; 44 bottomView.backgroundColor = UIColor.redColor;
39 bottomView.layer.borderColor = UIColor.blackColor.CGColor; 45 bottomView.layer.borderColor = UIColor.blackColor.CGColor;
40 bottomView.layer.borderWidth = 2; 46 bottomView.layer.borderWidth = 2;
41 [self.view addSubview:bottomView]; 47 [self.view addSubview:bottomView];
42 48
43 - // TODO find way that avoids casting  
44 - // layoutGuides are actually UIView subclasses so can be used in Masonry  
45 - // However casting to UIView is not ideal if Apple decides to change underlying implementation of layoutGuides this will break  
46 [topView makeConstraints:^(MASConstraintMaker *make) { 49 [topView makeConstraints:^(MASConstraintMaker *make) {
47 - UIView *topLayoutGuide = (id)self.topLayoutGuide;  
48 - make.top.equalTo(topLayoutGuide.bottom); 50 + make.top.equalTo(self.mas_topLayoutGuide);
49 make.left.equalTo(self.view); 51 make.left.equalTo(self.view);
50 make.right.equalTo(self.view); 52 make.right.equalTo(self.view);
51 make.height.equalTo(@40); 53 make.height.equalTo(@40);
52 }]; 54 }];
53 55
  56 + [topSubview makeConstraints:^(MASConstraintMaker *make) {
  57 + make.top.equalTo(self.mas_topLayoutGuide);
  58 + make.centerX.equalTo(@0);
  59 + make.width.equalTo(@20);
  60 + make.height.equalTo(@20);
  61 + }];
  62 +
54 [bottomView makeConstraints:^(MASConstraintMaker *make) { 63 [bottomView makeConstraints:^(MASConstraintMaker *make) {
55 - UIView *bottomLayoutGuide = (id)self.bottomLayoutGuide;  
56 - make.bottom.equalTo(bottomLayoutGuide.top); 64 + make.bottom.equalTo(self.mas_bottomLayoutGuide);
57 make.left.equalTo(self.view); 65 make.left.equalTo(self.view);
58 make.right.equalTo(self.view); 66 make.right.equalTo(self.view);
59 make.height.equalTo(@40); 67 make.height.equalTo(@40);
@@ -53,6 +53,10 @@ @@ -53,6 +53,10 @@
53 3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DC1AD5A0470053CC65 /* MASCompositeConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; }; 53 3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DC1AD5A0470053CC65 /* MASCompositeConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; };
54 3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05ED1AD5A0470053CC65 /* NSLayoutConstraint+MASDebugAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 54 3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05ED1AD5A0470053CC65 /* NSLayoutConstraint+MASDebugAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
55 3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DE1AD5A0470053CC65 /* MASConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55 3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DE1AD5A0470053CC65 /* MASConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; };
  56 + 4473548D1B39F772004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
  57 + 4473548E1B39F772004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; };
  58 + 447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; };
  59 + 447354931B3A18B9004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
56 /* End PBXBuildFile section */ 60 /* End PBXBuildFile section */
57 61
58 /* Begin PBXFileReference section */ 62 /* Begin PBXFileReference section */
@@ -82,6 +86,8 @@ @@ -82,6 +86,8 @@
82 3AED05F01AD5A0470053CC65 /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = "<group>"; }; 86 3AED05F01AD5A0470053CC65 /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = "<group>"; };
83 3AED05F11AD5A0470053CC65 /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = "<group>"; }; 87 3AED05F11AD5A0470053CC65 /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = "<group>"; };
84 3AED06271AD5A1400053CC65 /* Masonry.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Masonry.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 88 3AED06271AD5A1400053CC65 /* Masonry.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Masonry.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  89 + 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = "<group>"; };
  90 + 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = "<group>"; };
85 /* End PBXFileReference section */ 91 /* End PBXFileReference section */
86 92
87 /* Begin PBXFrameworksBuildPhase section */ 93 /* Begin PBXFrameworksBuildPhase section */
@@ -127,6 +133,8 @@ @@ -127,6 +133,8 @@
127 3AED05EF1AD5A0470053CC65 /* View+MASAdditions.h */, 133 3AED05EF1AD5A0470053CC65 /* View+MASAdditions.h */,
128 3AED05F01AD5A0470053CC65 /* View+MASAdditions.m */, 134 3AED05F01AD5A0470053CC65 /* View+MASAdditions.m */,
129 3AED05F11AD5A0470053CC65 /* View+MASShorthandAdditions.h */, 135 3AED05F11AD5A0470053CC65 /* View+MASShorthandAdditions.h */,
  136 + 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */,
  137 + 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */,
130 3AED05EA1AD5A0470053CC65 /* NSArray+MASAdditions.h */, 138 3AED05EA1AD5A0470053CC65 /* NSArray+MASAdditions.h */,
131 3AED05EB1AD5A0470053CC65 /* NSArray+MASAdditions.m */, 139 3AED05EB1AD5A0470053CC65 /* NSArray+MASAdditions.m */,
132 3AED05EC1AD5A0470053CC65 /* NSArray+MASShorthandAdditions.h */, 140 3AED05EC1AD5A0470053CC65 /* NSArray+MASShorthandAdditions.h */,
@@ -167,6 +175,7 @@ @@ -167,6 +175,7 @@
167 files = ( 175 files = (
168 3AED06051AD5A0470053CC65 /* View+MASAdditions.h in Headers */, 176 3AED06051AD5A0470053CC65 /* View+MASAdditions.h in Headers */,
169 3AED06071AD5A0470053CC65 /* View+MASShorthandAdditions.h in Headers */, 177 3AED06071AD5A0470053CC65 /* View+MASShorthandAdditions.h in Headers */,
  178 + 4473548D1B39F772004DACCB /* ViewController+MASAdditions.h in Headers */,
170 3AED05FC1AD5A0470053CC65 /* MASViewAttribute.h in Headers */, 179 3AED05FC1AD5A0470053CC65 /* MASViewAttribute.h in Headers */,
171 3AED05BD1AD59FD40053CC65 /* Masonry.h in Headers */, 180 3AED05BD1AD59FD40053CC65 /* Masonry.h in Headers */,
172 3AED05F91AD5A0470053CC65 /* MASLayoutConstraint.h in Headers */, 181 3AED05F91AD5A0470053CC65 /* MASLayoutConstraint.h in Headers */,
@@ -197,6 +206,7 @@ @@ -197,6 +206,7 @@
197 3AED061E1AD5A1400053CC65 /* MASUtilities.h in Headers */, 206 3AED061E1AD5A1400053CC65 /* MASUtilities.h in Headers */,
198 3AED061F1AD5A1400053CC65 /* NSArray+MASAdditions.h in Headers */, 207 3AED061F1AD5A1400053CC65 /* NSArray+MASAdditions.h in Headers */,
199 3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */, 208 3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */,
  209 + 447354931B3A18B9004DACCB /* ViewController+MASAdditions.h in Headers */,
200 3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */, 210 3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */,
201 3AED061D1AD5A1400053CC65 /* MASConstraint+Private.h in Headers */, 211 3AED061D1AD5A1400053CC65 /* MASConstraint+Private.h in Headers */,
202 3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */, 212 3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */,
@@ -298,6 +308,7 @@ @@ -298,6 +308,7 @@
298 files = ( 308 files = (
299 3AED06011AD5A0470053CC65 /* NSArray+MASAdditions.m in Sources */, 309 3AED06011AD5A0470053CC65 /* NSArray+MASAdditions.m in Sources */,
300 3AED05FD1AD5A0470053CC65 /* MASViewAttribute.m in Sources */, 310 3AED05FD1AD5A0470053CC65 /* MASViewAttribute.m in Sources */,
  311 + 4473548E1B39F772004DACCB /* ViewController+MASAdditions.m in Sources */,
301 3AED05FA1AD5A0470053CC65 /* MASLayoutConstraint.m in Sources */, 312 3AED05FA1AD5A0470053CC65 /* MASLayoutConstraint.m in Sources */,
302 3AED05F51AD5A0470053CC65 /* MASConstraint.m in Sources */, 313 3AED05F51AD5A0470053CC65 /* MASConstraint.m in Sources */,
303 3AED05FF1AD5A0470053CC65 /* MASViewConstraint.m in Sources */, 314 3AED05FF1AD5A0470053CC65 /* MASViewConstraint.m in Sources */,
@@ -318,6 +329,7 @@ @@ -318,6 +329,7 @@
318 3AED060D1AD5A1400053CC65 /* MASConstraint.m in Sources */, 329 3AED060D1AD5A1400053CC65 /* MASConstraint.m in Sources */,
319 3AED060E1AD5A1400053CC65 /* MASViewConstraint.m in Sources */, 330 3AED060E1AD5A1400053CC65 /* MASViewConstraint.m in Sources */,
320 3AED060F1AD5A1400053CC65 /* MASCompositeConstraint.m in Sources */, 331 3AED060F1AD5A1400053CC65 /* MASCompositeConstraint.m in Sources */,
  332 + 447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */,
321 3AED06101AD5A1400053CC65 /* MASConstraintMaker.m in Sources */, 333 3AED06101AD5A1400053CC65 /* MASConstraintMaker.m in Sources */,
322 3AED06111AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 334 3AED06111AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */,
323 3AED06121AD5A1400053CC65 /* View+MASAdditions.m in Sources */, 335 3AED06121AD5A1400053CC65 /* View+MASAdditions.m in Sources */,
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 12
13 #import <UIKit/UIKit.h> 13 #import <UIKit/UIKit.h>
14 #define MAS_VIEW UIView 14 #define MAS_VIEW UIView
  15 + #define MAS_VIEW_CONTROLLER UIViewController
15 #define MASEdgeInsets UIEdgeInsets 16 #define MASEdgeInsets UIEdgeInsets
16 17
17 typedef UILayoutPriority MASLayoutPriority; 18 typedef UILayoutPriority MASLayoutPriority;
@@ -15,21 +15,31 @@ @@ -15,21 +15,31 @@
15 @interface MASViewAttribute : NSObject 15 @interface MASViewAttribute : NSObject
16 16
17 /** 17 /**
18 - * The view which the reciever relates to 18 + * The view which the reciever relates to. Can be nil if item is not a view.
19 */ 19 */
20 @property (nonatomic, weak, readonly) MAS_VIEW *view; 20 @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 21
22 /** 22 /**
  23 + * The item which the reciever relates to.
  24 + */
  25 +@property (nonatomic, weak, readonly) id item;
  26 +
  27 +/**
23 * The attribute which the reciever relates to 28 * The attribute which the reciever relates to
24 */ 29 */
25 @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 30 @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
26 31
27 /** 32 /**
28 - * The designated initializer. 33 + * Convenience initializer.
29 */ 34 */
30 - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 35 - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
31 36
32 /** 37 /**
  38 + * The designated initializer.
  39 + */
  40 +- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
  41 +
  42 +/**
33 * Determine whether the layoutAttribute is a size attribute 43 * Determine whether the layoutAttribute is a size attribute
34 * 44 *
35 * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 45 * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
@@ -11,10 +11,16 @@ @@ -11,10 +11,16 @@
11 @implementation MASViewAttribute 11 @implementation MASViewAttribute
12 12
13 - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 13 - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
  14 + self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
  15 + return self;
  16 +}
  17 +
  18 +- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 self = [super init]; 19 self = [super init];
15 if (!self) return nil; 20 if (!self) return nil;
16 21
17 _view = view; 22 _view = view;
  23 + _item = item;
18 _layoutAttribute = layoutAttribute; 24 _layoutAttribute = layoutAttribute;
19 25
20 return self; 26 return self;
@@ -313,17 +313,16 @@ static char kInstalledConstraintsKey; @@ -313,17 +313,16 @@ static char kInstalledConstraintsKey;
313 return; 313 return;
314 } 314 }
315 315
316 - MAS_VIEW *firstLayoutItem = self.firstViewAttribute.view;  
317 - 316 + MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item;
318 NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 317 NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute;
319 - MAS_VIEW *secondLayoutItem = self.secondViewAttribute.view; 318 + MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item;
320 NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 319 NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute;
321 320
322 // alignment attributes must have a secondViewAttribute 321 // alignment attributes must have a secondViewAttribute
323 // therefore we assume that is refering to superview 322 // therefore we assume that is refering to superview
324 // eg make.left.equalTo(@10) 323 // eg make.left.equalTo(@10)
325 if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 324 if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) {
326 - secondLayoutItem = firstLayoutItem.superview; 325 + secondLayoutItem = self.firstViewAttribute.view.superview;
327 secondLayoutAttribute = firstLayoutAttribute; 326 secondLayoutAttribute = firstLayoutAttribute;
328 } 327 }
329 328
@@ -339,14 +338,16 @@ static char kInstalledConstraintsKey; @@ -339,14 +338,16 @@ static char kInstalledConstraintsKey;
339 layoutConstraint.priority = self.layoutPriority; 338 layoutConstraint.priority = self.layoutPriority;
340 layoutConstraint.mas_key = self.mas_key; 339 layoutConstraint.mas_key = self.mas_key;
341 340
342 - if (secondLayoutItem) {  
343 - MAS_VIEW *closestCommonSuperview = [firstLayoutItem mas_closestCommonSuperview:secondLayoutItem]; 341 + if (self.secondViewAttribute.view) {
  342 + MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];
344 NSAssert(closestCommonSuperview, 343 NSAssert(closestCommonSuperview,
345 @"couldn't find a common superview for %@ and %@", 344 @"couldn't find a common superview for %@ and %@",
346 - firstLayoutItem, secondLayoutItem); 345 + self.firstViewAttribute.view, self.secondViewAttribute.view);
347 self.installedView = closestCommonSuperview; 346 self.installedView = closestCommonSuperview;
  347 + } else if (self.firstViewAttribute.isSizeAttribute) {
  348 + self.installedView = self.firstViewAttribute.view;
348 } else { 349 } else {
349 - self.installedView = firstLayoutItem; 350 + self.installedView = self.firstViewAttribute.view.superview;
350 } 351 }
351 352
352 353
@@ -17,6 +17,7 @@ FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; @@ -17,6 +17,7 @@ FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
17 #import "MASUtilities.h" 17 #import "MASUtilities.h"
18 #import "View+MASAdditions.h" 18 #import "View+MASAdditions.h"
19 #import "View+MASShorthandAdditions.h" 19 #import "View+MASShorthandAdditions.h"
  20 +#import "ViewController+MASAdditions.h"
20 #import "NSArray+MASAdditions.h" 21 #import "NSArray+MASAdditions.h"
21 #import "NSArray+MASShorthandAdditions.h" 22 #import "NSArray+MASShorthandAdditions.h"
22 #import "MASConstraint.h" 23 #import "MASConstraint.h"
  1 +//
  2 +// UIViewController+MASAdditions.h
  3 +// Masonry
  4 +//
  5 +// Created by Craig Siemens on 2015-06-23.
  6 +//
  7 +//
  8 +
  9 +#import "MASUtilities.h"
  10 +#import "MASConstraintMaker.h"
  11 +#import "MASViewAttribute.h"
  12 +
  13 +#ifdef MAS_VIEW_CONTROLLER
  14 +
  15 +@interface MAS_VIEW_CONTROLLER (MASAdditions)
  16 +
  17 +/**
  18 + * following properties return a new MASViewAttribute with appropriate UILa 8youtGuide and NSLayoutAttribute
  19 + */
  20 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
  21 +@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
  22 +
  23 +@end
  24 +
  25 +#endif
  1 +//
  2 +// UIViewController+MASAdditions.m
  3 +// Masonry
  4 +//
  5 +// Created by Craig Siemens on 2015-06-23.
  6 +//
  7 +//
  8 +
  9 +#import "ViewController+MASAdditions.h"
  10 +
  11 +#ifdef MAS_VIEW_CONTROLLER
  12 +
  13 +@implementation MAS_VIEW_CONTROLLER (MASAdditions)
  14 +
  15 +- (MASViewAttribute *)mas_topLayoutGuide {
  16 + return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
  17 +}
  18 +
  19 +- (MASViewAttribute *)mas_bottomLayoutGuide {
  20 + return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
  21 +}
  22 +
  23 +@end
  24 +
  25 +#endif
1 PODS: 1 PODS:
2 - - Expecta (0.3.0)  
3 - - Masonry (0.5.0) 2 + - Expecta (1.0.0)
  3 + - Masonry (0.6.1)
4 4
5 DEPENDENCIES: 5 DEPENDENCIES:
6 - Expecta 6 - Expecta
@@ -8,10 +8,10 @@ DEPENDENCIES: @@ -8,10 +8,10 @@ DEPENDENCIES:
8 8
9 EXTERNAL SOURCES: 9 EXTERNAL SOURCES:
10 Masonry: 10 Masonry:
11 - :path: ./ 11 + :path: "./"
12 12
13 SPEC CHECKSUMS: 13 SPEC CHECKSUMS:
14 - Expecta: 322f1dc42610106a5ba9871b4924cf1635d80833  
15 - Masonry: bef482b29f00b33a2da916e1011af85f5d371d66 14 + Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024
  15 + Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa
16 16
17 -COCOAPODS: 0.32.1 17 +COCOAPODS: 0.37.2
1 -../../Expecta/src/EXPBackwardCompatibility.h  
1 -../../Expecta/src/EXPBlockDefinedMatcher.h  
1 -../../Expecta/src/EXPDefines.h  
1 -../../Expecta/src/EXPDoubleTuple.h  
1 -../../Expecta/src/EXPExpect.h  
1 -../../Expecta/src/EXPFloatTuple.h  
1 -../../Expecta/src/EXPMatcher.h  
1 -../../Expecta/src/matchers/EXPMatcherHelpers.h  
1 -../../Expecta/src/matchers/EXPMatchers+beCloseTo.h  
1 -../../Expecta/src/matchers/EXPMatchers+beFalsy.h  
1 -../../Expecta/src/matchers/EXPMatchers+beGreaterThan.h  
1 -../../Expecta/src/matchers/EXPMatchers+beGreaterThanOrEqualTo.h  
1 -../../Expecta/src/matchers/EXPMatchers+beIdenticalTo.h  
1 -../../Expecta/src/matchers/EXPMatchers+beInTheRangeOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+beInstanceOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+beKindOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+beLessThan.h  
1 -../../Expecta/src/matchers/EXPMatchers+beLessThanOrEqualTo.h  
1 -../../Expecta/src/matchers/EXPMatchers+beNil.h  
1 -../../Expecta/src/matchers/EXPMatchers+beSubclassOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+beSupersetOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+beTruthy.h  
1 -../../Expecta/src/matchers/EXPMatchers+beginWith.h  
1 -../../Expecta/src/matchers/EXPMatchers+conformTo.h  
1 -../../Expecta/src/matchers/EXPMatchers+contain.h  
1 -../../Expecta/src/matchers/EXPMatchers+endWith.h  
1 -../../Expecta/src/matchers/EXPMatchers+equal.h  
1 -../../Expecta/src/matchers/EXPMatchers+haveCountOf.h  
1 -../../Expecta/src/matchers/EXPMatchers+notify.h  
1 -../../Expecta/src/matchers/EXPMatchers+raise.h  
1 -../../Expecta/src/matchers/EXPMatchers+raiseWithReason.h  
1 -../../Expecta/src/matchers/EXPMatchers+respondTo.h  
1 -../../Expecta/src/matchers/EXPMatchers.h  
1 -../../Expecta/src/EXPUnsupportedObject.h  
1 -../../Expecta/src/Expecta.h  
1 -../../Expecta/src/ExpectaSupport.h  
1 -../../Expecta/src/NSObject+Expecta.h  
1 -../../Expecta/src/NSValue+Expecta.h  
1 -../../../Masonry/MASCompositeConstraint.h  
1 -../../../Masonry/MASConstraint+Private.h  
1 -../../../Masonry/MASConstraint.h  
1 -../../../Masonry/MASConstraintMaker.h  
1 -../../../Masonry/MASLayoutConstraint.h  
1 -../../../Masonry/MASUtilities.h  
1 -../../../Masonry/MASViewAttribute.h  
1 -../../../Masonry/MASViewConstraint.h  
1 -../../../Masonry/Masonry.h  
1 -../../../Masonry/NSArray+MASAdditions.h  
1 -../../../Masonry/NSArray+MASShorthandAdditions.h  
1 -../../../Masonry/NSLayoutConstraint+MASDebugAdditions.h  
1 -../../../Masonry/View+MASAdditions.h  
1 -../../../Masonry/View+MASShorthandAdditions.h  
@@ -8,6 +8,6 @@ @@ -8,6 +8,6 @@
8 @property (nonatomic, assign) double *values; 8 @property (nonatomic, assign) double *values;
9 @property (nonatomic, assign) size_t size; 9 @property (nonatomic, assign) size_t size;
10 10
11 -- (id)initWithDoubleValues:(double *)values size:(size_t)size; 11 +- (instancetype)initWithDoubleValues:(double *)values size:(size_t)size NS_DESIGNATED_INITIALIZER;
12 12
13 @end 13 @end
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 @synthesize values = _values, size = _size; 5 @synthesize values = _values, size = _size;
6 6
7 -- (id)initWithDoubleValues:(double *)values size:(size_t)size { 7 +- (instancetype)initWithDoubleValues:(double *)values size:(size_t)size {
8 if ((self = [super init])) { 8 if ((self = [super init])) {
9 self.values = malloc(sizeof(double) * size); 9 self.values = malloc(sizeof(double) * size);
10 memcpy(self.values, values, sizeof(double) * size); 10 memcpy(self.values, values, sizeof(double) * size);
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 char *_fileName; 9 char *_fileName;
10 BOOL _negative; 10 BOOL _negative;
11 BOOL _asynchronous; 11 BOOL _asynchronous;
  12 + NSTimeInterval _timeout;
12 } 13 }
13 14
14 @property(nonatomic, copy) EXPIdBlock actualBlock; 15 @property(nonatomic, copy) EXPIdBlock actualBlock;
@@ -18,14 +19,16 @@ @@ -18,14 +19,16 @@
18 @property(nonatomic) const char *fileName; 19 @property(nonatomic) const char *fileName;
19 @property(nonatomic) BOOL negative; 20 @property(nonatomic) BOOL negative;
20 @property(nonatomic) BOOL asynchronous; 21 @property(nonatomic) BOOL asynchronous;
  22 +@property(nonatomic) NSTimeInterval timeout;
21 23
22 @property(nonatomic, readonly) EXPExpect *to; 24 @property(nonatomic, readonly) EXPExpect *to;
23 @property(nonatomic, readonly) EXPExpect *toNot; 25 @property(nonatomic, readonly) EXPExpect *toNot;
24 @property(nonatomic, readonly) EXPExpect *notTo; 26 @property(nonatomic, readonly) EXPExpect *notTo;
25 @property(nonatomic, readonly) EXPExpect *will; 27 @property(nonatomic, readonly) EXPExpect *will;
26 @property(nonatomic, readonly) EXPExpect *willNot; 28 @property(nonatomic, readonly) EXPExpect *willNot;
  29 +@property(nonatomic, readonly) EXPExpect *(^after)(NSTimeInterval timeInterval);
27 30
28 -- (id)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName; 31 +- (instancetype)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName NS_DESIGNATED_INITIALIZER;
29 + (EXPExpect *)expectWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName; 32 + (EXPExpect *)expectWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName;
30 33
31 - (void)applyMatcher:(id<EXPMatcher>)matcher; 34 - (void)applyMatcher:(id<EXPMatcher>)matcher;
@@ -37,6 +40,6 @@ @@ -37,6 +40,6 @@
37 EXPExpect *_expectation; 40 EXPExpect *_expectation;
38 SEL _selector; 41 SEL _selector;
39 } 42 }
40 -- (id)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector;  
41 -- (void (^)(void))dispatch; 43 +- (instancetype)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector NS_DESIGNATED_INITIALIZER;
  44 +@property (nonatomic, readonly, copy) void (^dispatch)(void);
42 @end 45 @end
@@ -14,23 +14,26 @@ @@ -14,23 +14,26 @@
14 toNot, 14 toNot,
15 notTo, 15 notTo,
16 will, 16 will,
17 - willNot; 17 + willNot,
  18 + after;
18 19
19 @synthesize 20 @synthesize
20 actualBlock=_actualBlock, 21 actualBlock=_actualBlock,
21 testCase=_testCase, 22 testCase=_testCase,
22 negative=_negative, 23 negative=_negative,
23 asynchronous=_asynchronous, 24 asynchronous=_asynchronous,
  25 + timeout=_timeout,
24 lineNumber=_lineNumber, 26 lineNumber=_lineNumber,
25 fileName=_fileName; 27 fileName=_fileName;
26 28
27 -- (id)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName { 29 +- (instancetype)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName {
28 self = [super init]; 30 self = [super init];
29 if(self) { 31 if(self) {
30 self.actualBlock = actualBlock; 32 self.actualBlock = actualBlock;
31 self.testCase = testCase; 33 self.testCase = testCase;
32 self.negative = NO; 34 self.negative = NO;
33 self.asynchronous = NO; 35 self.asynchronous = NO;
  36 + self.timeout = [Expecta asynchronousTestTimeout];
34 self.lineNumber = lineNumber; 37 self.lineNumber = lineNumber;
35 self.fileName = fileName; 38 self.fileName = fileName;
36 } 39 }
@@ -39,7 +42,7 @@ @@ -39,7 +42,7 @@
39 42
40 - (void)dealloc 43 - (void)dealloc
41 { 44 {
42 - self.actualBlock = nil; 45 + _actualBlock = nil;
43 [super dealloc]; 46 [super dealloc];
44 } 47 }
45 48
@@ -71,6 +74,17 @@ @@ -71,6 +74,17 @@
71 return self.will.toNot; 74 return self.will.toNot;
72 } 75 }
73 76
  77 +- (EXPExpect *(^)(NSTimeInterval))after
  78 +{
  79 + EXPExpect * (^block)(NSTimeInterval) = [^EXPExpect *(NSTimeInterval timeout) {
  80 + self.asynchronous = YES;
  81 + self.timeout = timeout;
  82 + return self;
  83 + } copy];
  84 +
  85 + return [block autorelease];
  86 +}
  87 +
74 #pragma mark - 88 #pragma mark -
75 89
76 - (id)actual { 90 - (id)actual {
@@ -98,7 +112,7 @@ @@ -98,7 +112,7 @@
98 } else { 112 } else {
99 BOOL matchResult = NO; 113 BOOL matchResult = NO;
100 if(self.asynchronous) { 114 if(self.asynchronous) {
101 - NSTimeInterval timeOut = [Expecta asynchronousTestTimeout]; 115 + NSTimeInterval timeOut = self.timeout;
102 NSDate *expiryDate = [NSDate dateWithTimeIntervalSinceNow:timeOut]; 116 NSDate *expiryDate = [NSDate dateWithTimeIntervalSinceNow:timeOut];
103 while(1) { 117 while(1) {
104 matchResult = [matcher matches:*actual]; 118 matchResult = [matcher matches:*actual];
@@ -164,7 +178,7 @@ @@ -164,7 +178,7 @@
164 178
165 @implementation EXPDynamicPredicateMatcher 179 @implementation EXPDynamicPredicateMatcher
166 180
167 -- (id)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector 181 +- (instancetype)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector
168 { 182 {
169 if ((self = [super init])) { 183 if ((self = [super init])) {
170 _expectation = expectation; 184 _expectation = expectation;
@@ -8,6 +8,6 @@ @@ -8,6 +8,6 @@
8 @property (nonatomic, assign) float *values; 8 @property (nonatomic, assign) float *values;
9 @property (nonatomic, assign) size_t size; 9 @property (nonatomic, assign) size_t size;
10 10
11 -- (id)initWithFloatValues:(float *)values size:(size_t)size; 11 +- (instancetype)initWithFloatValues:(float *)values size:(size_t)size NS_DESIGNATED_INITIALIZER;
12 12
13 @end 13 @end
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 @synthesize values = _values, size = _size; 5 @synthesize values = _values, size = _size;
6 6
7 -- (id)initWithFloatValues:(float *)values size:(size_t)size { 7 +- (instancetype)initWithFloatValues:(float *)values size:(size_t)size {
8 if ((self = [super init])) { 8 if ((self = [super init])) {
9 self.values = malloc(sizeof(float) * size); 9 self.values = malloc(sizeof(float) * size);
10 memcpy(self.values, values, sizeof(float) * size); 10 memcpy(self.values, values, sizeof(float) * size);
@@ -30,6 +30,16 @@ @@ -30,6 +30,16 @@
30 return NO; 30 return NO;
31 } 31 }
32 32
  33 +- (NSUInteger)hash
  34 +{
  35 + NSUInteger prime = 31;
  36 + NSUInteger hash = 0;
  37 + for (int i=0; i<self.size; i++) {
  38 + hash = prime * hash + (NSUInteger)self.values[i];
  39 + }
  40 + return hash;
  41 +}
  42 +
33 - (NSString *)description { 43 - (NSString *)description {
34 if (self.size == 2) { 44 if (self.size == 2) {
35 return [NSString stringWithFormat:@"Float tuple: {%f, %f}", self.values[0], self.values[1]]; 45 return [NSString stringWithFormat:@"Float tuple: {%f, %f}", self.values[0], self.values[1]];
@@ -6,6 +6,6 @@ @@ -6,6 +6,6 @@
6 6
7 @property (nonatomic, retain) NSString *type; 7 @property (nonatomic, retain) NSString *type;
8 8
9 -- (id)initWithType:(NSString *)type; 9 +- (instancetype)initWithType:(NSString *)type NS_DESIGNATED_INITIALIZER;
10 10
11 @end 11 @end
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 @synthesize type=_type; 5 @synthesize type=_type;
6 6
7 -- (id)initWithType:(NSString *)type { 7 +- (instancetype)initWithType:(NSString *)type {
8 self = [super init]; 8 self = [super init];
9 if(self) { 9 if(self) {
10 self.type = type; 10 self.type = type;
  1 +#import <Foundation/Foundation.h>
  2 +
  3 +//! Project version number for Expecta.
  4 +FOUNDATION_EXPORT double ExpectaVersionNumber;
  5 +
  6 +//! Project version string for Expecta.
  7 +FOUNDATION_EXPORT const unsigned char ExpectaVersionString[];
  8 +
  9 +#import <Expecta/ExpectaObject.h>
  10 +#import <Expecta/ExpectaSupport.h>
  11 +#import <Expecta/EXPMatchers.h>
  12 +
  13 +// Enable shorthand by default
  14 +#define expect(...) EXP_expect((__VA_ARGS__))
  15 +#define failure(...) EXP_failure((__VA_ARGS__))
1 #import <Foundation/Foundation.h> 1 #import <Foundation/Foundation.h>
2 -#import "ExpectaSupport.h"  
3 2
4 #define EXPObjectify(value) _EXPObjectify(@encode(__typeof__((value))), (value)) 3 #define EXPObjectify(value) _EXPObjectify(@encode(__typeof__((value))), (value))
5 -  
6 #define EXP_expect(actual) _EXP_expect(self, __LINE__, __FILE__, ^id{ return EXPObjectify((actual)); }) 4 #define EXP_expect(actual) _EXP_expect(self, __LINE__, __FILE__, ^id{ return EXPObjectify((actual)); })
7 -  
8 #define EXPMatcherInterface(matcherName, matcherArguments) _EXPMatcherInterface(matcherName, matcherArguments) 5 #define EXPMatcherInterface(matcherName, matcherArguments) _EXPMatcherInterface(matcherName, matcherArguments)
9 #define EXPMatcherImplementationBegin(matcherName, matcherArguments) _EXPMatcherImplementationBegin(matcherName, matcherArguments) 6 #define EXPMatcherImplementationBegin(matcherName, matcherArguments) _EXPMatcherImplementationBegin(matcherName, matcherArguments)
10 #define EXPMatcherImplementationEnd _EXPMatcherImplementationEnd 7 #define EXPMatcherImplementationEnd _EXPMatcherImplementationEnd
  8 +#define EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments) _EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments)
11 9
12 -#import "EXPMatchers.h"  
13 -  
14 -#ifdef EXP_SHORTHAND  
15 -# define expect(actual) EXP_expect((actual))  
16 -#endif 10 +#define EXP_failure(message) EXPFail(self, __LINE__, __FILE__, message)
17 11
18 -#ifdef EXP_OLD_SYNTAX  
19 -# import "EXPBackwardCompatibility.h"  
20 -#endif  
21 12
22 @interface Expecta : NSObject 13 @interface Expecta : NSObject
23 14
1 -#import "Expecta.h" 1 +#import "ExpectaObject.h"
2 2
3 @implementation Expecta 3 @implementation Expecta
4 4
1 #import "EXPExpect.h" 1 #import "EXPExpect.h"
2 #import "EXPBlockDefinedMatcher.h" 2 #import "EXPBlockDefinedMatcher.h"
3 3
  4 +#ifdef __cplusplus
  5 +extern "C" {
  6 +#endif
  7 +
4 id _EXPObjectify(const char *type, ...); 8 id _EXPObjectify(const char *type, ...);
5 EXPExpect *_EXP_expect(id testCase, int lineNumber, const char *fileName, EXPIdBlock actualBlock); 9 EXPExpect *_EXP_expect(id testCase, int lineNumber, const char *fileName, EXPIdBlock actualBlock);
6 10
@@ -54,3 +58,16 @@ EXPFixCategoriesBug(EXPMatcher##matcherName##Matcher); \ @@ -54,3 +58,16 @@ EXPFixCategoriesBug(EXPMatcher##matcherName##Matcher); \
54 return _EXP_autorelease(matcherBlock); \ 58 return _EXP_autorelease(matcherBlock); \
55 } \ 59 } \
56 @end 60 @end
  61 +
  62 +#define _EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments) \
  63 +EXPFixCategoriesBug(EXPMatcher##newMatcherName##Matcher); \
  64 +@implementation EXPExpect (newMatcherName##Matcher) \
  65 +@dynamic newMatcherName;\
  66 +- (void(^) matcherArguments) newMatcherName { \
  67 + return [self oldMatcherName]; \
  68 +}\
  69 +@end
  70 +
  71 +#ifdef __cplusplus
  72 +}
  73 +#endif
@@ -7,12 +7,6 @@ @@ -7,12 +7,6 @@
7 #import "EXPDefines.h" 7 #import "EXPDefines.h"
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 9
10 -@interface NSException (ExpectaSenTestFailure)  
11 -  
12 -+ (NSException *)failureInFile:(NSString *)filename atLine:(int)lineNumber withDescription:(NSString *)formatString, ...;  
13 -  
14 -@end  
15 -  
16 @interface NSObject (ExpectaXCTestRecordFailure) 10 @interface NSObject (ExpectaXCTestRecordFailure)
17 11
18 // suppress warning 12 // suppress warning
@@ -26,44 +20,44 @@ id _EXPObjectify(const char *type, ...) { @@ -26,44 +20,44 @@ id _EXPObjectify(const char *type, ...) {
26 id obj = nil; 20 id obj = nil;
27 if(strcmp(type, @encode(char)) == 0) { 21 if(strcmp(type, @encode(char)) == 0) {
28 char actual = (char)va_arg(v, int); 22 char actual = (char)va_arg(v, int);
29 - obj = [NSNumber numberWithChar:actual]; 23 + obj = @(actual);
30 } else if(strcmp(type, @encode(_Bool)) == 0) { 24 } else if(strcmp(type, @encode(_Bool)) == 0) {
31 _Static_assert(sizeof(_Bool) <= sizeof(int), "Expected _Bool to be subject to vararg type promotion"); 25 _Static_assert(sizeof(_Bool) <= sizeof(int), "Expected _Bool to be subject to vararg type promotion");
32 _Bool actual = (_Bool)va_arg(v, int); 26 _Bool actual = (_Bool)va_arg(v, int);
33 - obj = [NSNumber numberWithBool:actual]; 27 + obj = @(actual);
34 } else if(strcmp(type, @encode(double)) == 0) { 28 } else if(strcmp(type, @encode(double)) == 0) {
35 double actual = (double)va_arg(v, double); 29 double actual = (double)va_arg(v, double);
36 - obj = [NSNumber numberWithDouble:actual]; 30 + obj = @(actual);
37 } else if(strcmp(type, @encode(float)) == 0) { 31 } else if(strcmp(type, @encode(float)) == 0) {
38 float actual = (float)va_arg(v, double); 32 float actual = (float)va_arg(v, double);
39 - obj = [NSNumber numberWithFloat:actual]; 33 + obj = @(actual);
40 } else if(strcmp(type, @encode(int)) == 0) { 34 } else if(strcmp(type, @encode(int)) == 0) {
41 int actual = (int)va_arg(v, int); 35 int actual = (int)va_arg(v, int);
42 - obj = [NSNumber numberWithInt:actual]; 36 + obj = @(actual);
43 } else if(strcmp(type, @encode(long)) == 0) { 37 } else if(strcmp(type, @encode(long)) == 0) {
44 long actual = (long)va_arg(v, long); 38 long actual = (long)va_arg(v, long);
45 - obj = [NSNumber numberWithLong:actual]; 39 + obj = @(actual);
46 } else if(strcmp(type, @encode(long long)) == 0) { 40 } else if(strcmp(type, @encode(long long)) == 0) {
47 long long actual = (long long)va_arg(v, long long); 41 long long actual = (long long)va_arg(v, long long);
48 - obj = [NSNumber numberWithLongLong:actual]; 42 + obj = @(actual);
49 } else if(strcmp(type, @encode(short)) == 0) { 43 } else if(strcmp(type, @encode(short)) == 0) {
50 short actual = (short)va_arg(v, int); 44 short actual = (short)va_arg(v, int);
51 - obj = [NSNumber numberWithShort:actual]; 45 + obj = @(actual);
52 } else if(strcmp(type, @encode(unsigned char)) == 0) { 46 } else if(strcmp(type, @encode(unsigned char)) == 0) {
53 unsigned char actual = (unsigned char)va_arg(v, unsigned int); 47 unsigned char actual = (unsigned char)va_arg(v, unsigned int);
54 - obj = [NSNumber numberWithUnsignedChar:actual]; 48 + obj = @(actual);
55 } else if(strcmp(type, @encode(unsigned int)) == 0) { 49 } else if(strcmp(type, @encode(unsigned int)) == 0) {
56 unsigned int actual = (int)va_arg(v, unsigned int); 50 unsigned int actual = (int)va_arg(v, unsigned int);
57 - obj = [NSNumber numberWithUnsignedInt:actual]; 51 + obj = @(actual);
58 } else if(strcmp(type, @encode(unsigned long)) == 0) { 52 } else if(strcmp(type, @encode(unsigned long)) == 0) {
59 unsigned long actual = (unsigned long)va_arg(v, unsigned long); 53 unsigned long actual = (unsigned long)va_arg(v, unsigned long);
60 - obj = [NSNumber numberWithUnsignedLong:actual]; 54 + obj = @(actual);
61 } else if(strcmp(type, @encode(unsigned long long)) == 0) { 55 } else if(strcmp(type, @encode(unsigned long long)) == 0) {
62 unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 56 unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long);
63 - obj = [NSNumber numberWithUnsignedLongLong:actual]; 57 + obj = @(actual);
64 } else if(strcmp(type, @encode(unsigned short)) == 0) { 58 } else if(strcmp(type, @encode(unsigned short)) == 0) {
65 unsigned short actual = (unsigned short)va_arg(v, unsigned int); 59 unsigned short actual = (unsigned short)va_arg(v, unsigned int);
66 - obj = [NSNumber numberWithUnsignedShort:actual]; 60 + obj = @(actual);
67 } else if(strstr(type, @encode(EXPBasicBlock)) != NULL) { 61 } else if(strstr(type, @encode(EXPBasicBlock)) != NULL) {
68 // @encode(EXPBasicBlock) returns @? as of clang 4.1. 62 // @encode(EXPBasicBlock) returns @? as of clang 4.1.
69 // This condition must occur before the test for id/class type, 63 // This condition must occur before the test for id/class type,
@@ -113,14 +107,9 @@ void EXPFail(id testCase, int lineNumber, const char *fileName, NSString *messag @@ -113,14 +107,9 @@ void EXPFail(id testCase, int lineNumber, const char *fileName, NSString *messag
113 NSString *reason = [NSString stringWithFormat:@"%s:%d %@", fileName, lineNumber, message]; 107 NSString *reason = [NSString stringWithFormat:@"%s:%d %@", fileName, lineNumber, message];
114 NSException *exception = [NSException exceptionWithName:@"Expecta Error" reason:reason userInfo:nil]; 108 NSException *exception = [NSException exceptionWithName:@"Expecta Error" reason:reason userInfo:nil];
115 109
116 - if(testCase && [testCase respondsToSelector:@selector(failWithException:)]) {  
117 - if([[(Class)objc_getMetaClass("NSException") class] instancesRespondToSelector:@selector(failureInFile:atLine:withDescription:)]) {  
118 - exception = [NSException failureInFile:[NSString stringWithUTF8String:fileName] atLine:lineNumber withDescription:message];  
119 - }  
120 - [testCase failWithException:exception];  
121 - } else if(testCase && [testCase respondsToSelector:@selector(recordFailureWithDescription:inFile:atLine:expected:)]){ 110 + if(testCase && [testCase respondsToSelector:@selector(recordFailureWithDescription:inFile:atLine:expected:)]){
122 [testCase recordFailureWithDescription:message 111 [testCase recordFailureWithDescription:message
123 - inFile:[NSString stringWithUTF8String:fileName] 112 + inFile:@(fileName)
124 atLine:lineNumber 113 atLine:lineNumber
125 expected:NO]; 114 expected:NO];
126 } else { 115 } else {
@@ -157,7 +146,7 @@ NSString *EXPDescribeObject(id obj) { @@ -157,7 +146,7 @@ NSString *EXPDescribeObject(id obj) {
157 } else if([obj isKindOfClass:[NSDictionary class]]) { 146 } else if([obj isKindOfClass:[NSDictionary class]]) {
158 NSMutableArray *arr = [NSMutableArray arrayWithCapacity:[obj count]]; 147 NSMutableArray *arr = [NSMutableArray arrayWithCapacity:[obj count]];
159 for(id k in obj) { 148 for(id k in obj) {
160 - id v = [obj objectForKey:k]; 149 + id v = obj[k];
161 [arr addObject:[NSString stringWithFormat:@"%@ = %@;",EXPDescribeObject(k), EXPDescribeObject(v)]]; 150 [arr addObject:[NSString stringWithFormat:@"%@ = %@;",EXPDescribeObject(k), EXPDescribeObject(v)]];
162 } 151 }
163 description = [NSString stringWithFormat:@"{%@}", [arr componentsJoinedByString:@" "]]; 152 description = [NSString stringWithFormat:@"{%@}", [arr componentsJoinedByString:@" "]];
@@ -170,18 +159,18 @@ NSString *EXPDescribeObject(id obj) { @@ -170,18 +159,18 @@ NSString *EXPDescribeObject(id obj) {
170 } 159 }
171 160
172 void EXP_prerequisite(EXPBoolBlock block) { 161 void EXP_prerequisite(EXPBoolBlock block) {
173 - [[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setPrerequisiteBlock:block]; 162 + [[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setPrerequisiteBlock:block];
174 } 163 }
175 164
176 void EXP_match(EXPBoolBlock block) { 165 void EXP_match(EXPBoolBlock block) {
177 - [[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setMatchBlock:block]; 166 + [[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setMatchBlock:block];
178 } 167 }
179 168
180 void EXP_failureMessageForTo(EXPStringBlock block) { 169 void EXP_failureMessageForTo(EXPStringBlock block) {
181 - [[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setFailureMessageForToBlock:block]; 170 + [[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setFailureMessageForToBlock:block];
182 } 171 }
183 172
184 void EXP_failureMessageForNotTo(EXPStringBlock block) { 173 void EXP_failureMessageForNotTo(EXPStringBlock block) {
185 - [[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setFailureMessageForNotToBlock:block]; 174 + [[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setFailureMessageForNotToBlock:block];
186 } 175 }
187 176
@@ -6,5 +6,5 @@ EXPMatcherInterface(beIdenticalTo, (void *expected)); // to aid code completion @@ -6,5 +6,5 @@ EXPMatcherInterface(beIdenticalTo, (void *expected)); // to aid code completion
6 #if __has_feature(objc_arc) 6 #if __has_feature(objc_arc)
7 #define beIdenticalTo(expected) _beIdenticalTo((__bridge void*)expected) 7 #define beIdenticalTo(expected) _beIdenticalTo((__bridge void*)expected)
8 #else 8 #else
9 -#define beIdenticalTo _beIdenticalTo 9 +#define beIdenticalTo(expected) _beIdenticalTo(expected)
10 #endif 10 #endif
1 #import "EXPMatchers+equal.h" 1 #import "EXPMatchers+equal.h"
2 #import "EXPMatcherHelpers.h" 2 #import "EXPMatcherHelpers.h"
3 3
4 -EXPMatcherImplementationBegin(beIdenticalTo, (void *expected)) { 4 +EXPMatcherImplementationBegin(_beIdenticalTo, (void *expected)) {
5 match(^BOOL{ 5 match(^BOOL{
6 if(actual == expected) { 6 if(actual == expected) {
7 return YES; 7 return YES;
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(beInstanceOf, (Class expected));
  4 +EXPMatcherInterface(beAnInstanceOf, (Class expected));
  5 +EXPMatcherInterface(beMemberOf, (Class expected));
  6 +EXPMatcherInterface(beAMemberOf, (Class expected));
@@ -25,3 +25,7 @@ EXPMatcherImplementationBegin(beInstanceOf, (Class expected)) { @@ -25,3 +25,7 @@ EXPMatcherImplementationBegin(beInstanceOf, (Class expected)) {
25 }); 25 });
26 } 26 }
27 EXPMatcherImplementationEnd 27 EXPMatcherImplementationEnd
  28 +
  29 +EXPMatcherAliasImplementation(beAnInstanceOf, beInstanceOf, (Class expected));
  30 +EXPMatcherAliasImplementation(beMemberOf, beInstanceOf, (Class expected));
  31 +EXPMatcherAliasImplementation(beAMemberOf, beInstanceOf, (Class expected));
  1 +#import "Expecta.h"
  2 +
  3 +EXPMatcherInterface(beKindOf, (Class expected));
  4 +EXPMatcherInterface(beAKindOf, (Class expected));
@@ -25,3 +25,5 @@ EXPMatcherImplementationBegin(beKindOf, (Class expected)) { @@ -25,3 +25,5 @@ EXPMatcherImplementationBegin(beKindOf, (Class expected)) {
25 }); 25 });
26 } 26 }
27 EXPMatcherImplementationEnd 27 EXPMatcherImplementationEnd
  28 +
  29 +EXPMatcherAliasImplementation(beAKindOf, beKindOf, (Class expected));