Skip to content

Commit 353ce7e

Browse files
committed
Changes to support moved class methods from 1583f7b
- Fix usage of moved APIs in unit tests and demo apps - Add a new set of unit tests for the constraint identifier APIs
1 parent 1583f7b commit 353ce7e

13 files changed

Lines changed: 174 additions & 50 deletions

PureLayout/Example-Mac/ALMacViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ - (void)setupDemo4
164164
[view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:previousView withOffset:10.0];
165165
// The orange view will be allowed to change its size if it conflicts with a required constraint
166166
NSLayoutPriority priority = (view == self.orangeView) ? NSLayoutPriorityDefaultHigh + 1 : NSLayoutPriorityRequired;
167-
[NSView autoSetPriority:priority forConstraints:^{
167+
[NSLayoutConstraint autoSetPriority:priority forConstraints:^{
168168
[view autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:previousView withMultiplier:1.5];
169169
[view autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:previousView withMultiplier:2.0];
170170
}];

PureLayout/Example-iOS/Demos/ALiOSDemo10ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ - (void)updateViewConstraints
5353

5454
// Create and install the constraints that define the horizontal layout, because this is the one we're starting in.
5555
// Note that we use autoCreateAndInstallConstraints() here in order to easily collect all the constraints into a single array.
56-
self.horizontalLayoutConstraints = [UIView autoCreateAndInstallConstraints:^{
56+
self.horizontalLayoutConstraints = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
5757
[views autoSetViewsDimension:ALDimensionHeight toSize:40.0];
5858
[views autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:10.0 insetSpacing:YES matchedSizes:YES];
5959
[self.redView autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
@@ -62,7 +62,7 @@ - (void)updateViewConstraints
6262
// Create the constraints that define the vertical layout, but don't install any of them - just store them for now.
6363
// Note that we use autoCreateConstraintsWithoutInstalling() here in order to both prevent the constraints from being installed automatically,
6464
// and to easily collect all the constraints into a single array.
65-
self.verticalLayoutConstraints = [UIView autoCreateConstraintsWithoutInstalling:^{
65+
self.verticalLayoutConstraints = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
6666
[views autoSetViewsDimension:ALDimensionWidth toSize:60.0];
6767
[views autoDistributeViewsAlongAxis:ALAxisVertical alignedTo:ALAttributeVertical withFixedSpacing:70.0 insetSpacing:YES matchedSizes:YES];
6868
[self.redView autoAlignAxisToSuperviewAxis:ALAxisVertical];

PureLayout/Example-iOS/Demos/ALiOSDemo6ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ - (void)updateViewConstraints
4545
// Add constraints that set the size of the blueView to a ridiculously large size, but set the priority of these constraints
4646
// to a lower value than Required. This allows the Auto Layout solver to let these constraints be broken if one or both of
4747
// them conflict with higher-priority constraint(s), such as the above 4 edge constraints.
48-
[UIView autoSetPriority:UILayoutPriorityDefaultHigh forConstraints:^{
48+
[NSLayoutConstraint autoSetPriority:UILayoutPriorityDefaultHigh forConstraints:^{
4949
[self.blueView autoSetDimensionsToSize:CGSizeMake(10000.0, 10000.0)];
5050
}];
5151

PureLayout/Example-iOS/Demos/ALiOSDemo8ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (void)updateViewConstraints
4747
it will raise an exception, and you will see these identifiers show up next to the constraint in the console.
4848
*/
4949

50-
[UIView autoSetIdentifier:@"Pin Container View Edges" forConstraints:^{
50+
[NSLayoutConstraint autoSetIdentifier:@"Pin Container View Edges" forConstraints:^{
5151
[self.containerView autoPinToTopLayoutGuideOfViewController:self withInset:10.0];
5252
[self.containerView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0.0, 10.0, 10.0, 10.0) excludingEdge:ALEdgeTop];
5353
}];
@@ -74,7 +74,7 @@ This lets you chain the identifier call right after creating the constraint(s),
7474
But because we have provided human-readable identifiers, notice how easy it is to figure out which constraints are
7575
conflicting, and which constraint shouldn't be there!
7676
*/
77-
[UIView autoSetIdentifier:@"Bad Constraints That Break Things" forConstraints:^{
77+
[NSLayoutConstraint autoSetIdentifier:@"Bad Constraints That Break Things" forConstraints:^{
7878
// [self.redView autoAlignAxis:ALAxisVertical toSameAxisOfView:self.view withOffset:5.0]; // uncomment me and watch things blow up!
7979

8080
// [self.redView autoPinEdgeToSuperviewEdge:ALEdgeLeft]; // uncomment me and watch things blow up!

PureLayout/Example-iOS/Demos/iOSDemo10ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class iOSDemo10ViewController: UIViewController {
6969

7070
// Create and install the constraints that define the horizontal layout, because this is the one we're starting in.
7171
// Note that we use autoCreateAndInstallConstraints() here in order to easily collect all the constraints into a single array.
72-
horizontalLayoutConstraints = UIView.autoCreateAndInstallConstraints {
72+
horizontalLayoutConstraints = NSLayoutConstraint.autoCreateAndInstallConstraints {
7373
views.autoSetViewsDimension(.Height, toSize: 40.0)
7474
views.autoDistributeViewsAlongAxis(.Horizontal, alignedTo: .Horizontal, withFixedSpacing: 10.0, insetSpacing: true, matchedSizes: true)
7575
self.redView.autoAlignAxisToSuperviewAxis(.Horizontal)
@@ -78,7 +78,7 @@ class iOSDemo10ViewController: UIViewController {
7878
// Create the constraints that define the vertical layout, but don't install any of them - just store them for now.
7979
// Note that we use autoCreateConstraintsWithoutInstalling() here in order to both prevent the constraints from being installed automatically,
8080
// and to easily collect all the constraints into a single array.
81-
verticalLayoutConstraints = UIView.autoCreateConstraintsWithoutInstalling {
81+
verticalLayoutConstraints = NSLayoutConstraint.autoCreateConstraintsWithoutInstalling {
8282
views.autoSetViewsDimension(.Width, toSize: 60.0)
8383
views.autoDistributeViewsAlongAxis(.Vertical, alignedTo: .Vertical, withFixedSpacing: 70.0, insetSpacing: true, matchedSizes: true)
8484
self.redView.autoAlignAxisToSuperviewAxis(.Vertical)

PureLayout/Example-iOS/Demos/iOSDemo6ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class iOSDemo6ViewController: UIViewController {
4343
// Add constraints that set the size of the blueView to a ridiculously large size, but set the priority of these constraints
4444
// to a lower value than Required. This allows the Auto Layout solver to let these constraints be broken if one or both of
4545
// them conflict with higher-priority constraint(s), such as the above 4 edge constraints.
46-
UIView.autoSetPriority(UILayoutPriorityDefaultHigh) {
46+
NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultHigh) {
4747
blueView.autoSetDimensionsToSize(CGSize(width: 10000.0, height: 10000.0))
4848
}
4949

PureLayout/Example-iOS/Demos/iOSDemo8ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class iOSDemo8ViewController: UIViewController {
6262
it will raise an exception, and you will see these identifiers show up next to the constraint in the console.
6363
*/
6464

65-
UIView.autoSetIdentifier("Pin Container View Edges") {
65+
NSLayoutConstraint.autoSetIdentifier("Pin Container View Edges") {
6666
self.containerView.autoPinToTopLayoutGuideOfViewController(self, withInset: 10.0)
6767
self.containerView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsets(top: 0.0, left: 10.0, bottom: 10.0, right: 10.0), excludingEdge: .Top)
6868
}
@@ -88,7 +88,7 @@ class iOSDemo8ViewController: UIViewController {
8888
But because we have provided human-readable identifiers, notice how easy it is to figure out which constraints are
8989
conflicting, and which constraint shouldn't be there!
9090
*/
91-
UIView.autoSetIdentifier("Bad Constraints That Break Things") {
91+
NSLayoutConstraint.autoSetIdentifier("Bad Constraints That Break Things") {
9292
// self.redView.autoAlignAxis(.Vertical, toSameAxisOfView: self.view, withOffset: 5.0) // uncomment me and watch things blow up!
9393

9494
// self.redView.autoPinEdgeToSuperviewEdge(.Left) // uncomment me and watch things blow up!

PureLayout/PureLayout.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
A7371DC31B68792800DB94B6 /* PureLayoutBatchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A7371DC21B68792800DB94B6 /* PureLayoutBatchTests.m */; };
1111
A7371DC41B68792800DB94B6 /* PureLayoutBatchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A7371DC21B68792800DB94B6 /* PureLayoutBatchTests.m */; };
12+
A7D0FF361B8146370025AF37 /* PureLayoutIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D0FF351B8146370025AF37 /* PureLayoutIdentifierTests.m */; };
13+
A7D0FF371B8146370025AF37 /* PureLayoutIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D0FF351B8146370025AF37 /* PureLayoutIdentifierTests.m */; };
1214
A7D496591B7B084800A74818 /* ALiOSDemo2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B13DFF2319E773D100B26152 /* ALiOSDemo2ViewController.m */; };
1315
A7D4965A1B7B084800A74818 /* iOSDemo8ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DB5C951B7AEC83000ED37F /* iOSDemo8ViewController.swift */; };
1416
A7D4965B1B7B084800A74818 /* ALiOSDemo5ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B162DF6B19E9F6A800D56FEA /* ALiOSDemo5ViewController.m */; };
@@ -195,6 +197,7 @@
195197

196198
/* Begin PBXFileReference section */
197199
A7371DC21B68792800DB94B6 /* PureLayoutBatchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PureLayoutBatchTests.m; path = PureLayoutTests/PureLayoutBatchTests.m; sourceTree = "<group>"; };
200+
A7D0FF351B8146370025AF37 /* PureLayoutIdentifierTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PureLayoutIdentifierTests.m; path = PureLayoutTests/PureLayoutIdentifierTests.m; sourceTree = "<group>"; };
198201
A7D4964F1B7AF1D100A74818 /* iOSDemo9ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iOSDemo9ViewController.swift; path = "Example-iOS/Demos/iOSDemo9ViewController.swift"; sourceTree = SOURCE_ROOT; };
199202
A7D496511B7AF44D00A74818 /* iOSDemo10ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iOSDemo10ViewController.swift; path = "Example-iOS/Demos/iOSDemo10ViewController.swift"; sourceTree = SOURCE_ROOT; };
200203
A7D4967E1B7B084800A74818 /* Example-iOS-Xcode7.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-iOS-Xcode7.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -564,6 +567,7 @@
564567
B17D24C91956648700F2FD4B /* PureLayoutTestBase.m */,
565568
A7371DC21B68792800DB94B6 /* PureLayoutBatchTests.m */,
566569
B1089C1A195787C900339027 /* PureLayoutCenteringTests.m */,
570+
A7D0FF351B8146370025AF37 /* PureLayoutIdentifierTests.m */,
567571
B1089C1B195787C900339027 /* PureLayoutInstallationTests.m */,
568572
B1089C1C195787C900339027 /* PureLayoutInstantiationTests.m */,
569573
B1089C1D195787C900339027 /* PureLayoutInternalTests.m */,
@@ -978,6 +982,7 @@
978982
files = (
979983
B1089C29195787C900339027 /* PureLayoutPinEdgesTests.m in Sources */,
980984
B1089C23195787C900339027 /* PureLayoutInstallationTests.m in Sources */,
985+
A7D0FF361B8146370025AF37 /* PureLayoutIdentifierTests.m in Sources */,
981986
B1046B0B1A7F38930017187F /* NSLayoutConstraint+PureLayout.m in Sources */,
982987
B1089C27195787C900339027 /* PureLayoutInternalTests.m in Sources */,
983988
B1046A811A7F29F80017187F /* PureLayoutDistributeTests.m in Sources */,
@@ -1004,6 +1009,7 @@
10041009
B1089C22195787C900339027 /* PureLayoutCenteringTests.m in Sources */,
10051010
B1046B0D1A7F38930017187F /* NSArray+PureLayout.m in Sources */,
10061011
B1089C26195787C900339027 /* PureLayoutInstantiationTests.m in Sources */,
1012+
A7D0FF371B8146370025AF37 /* PureLayoutIdentifierTests.m in Sources */,
10071013
B1089C2E195787C900339027 /* PureLayoutRemovalTests.m in Sources */,
10081014
B1046A821A7F29F80017187F /* PureLayoutDistributeTests.m in Sources */,
10091015
B1089C2C195787C900339027 /* PureLayoutPriorityTests.m in Sources */,

PureLayout/PureLayoutTests/PureLayoutBatchTests.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ - (BOOL)noConstraintsAreActivated:(__NSArray_of(NSLayoutConstraint *) *)constrai
7979
- (void)testCreateAndInstallConstraints
8080
{
8181
__NSMutableArray_of(NSLayoutConstraint *) *createdConstraints = [NSMutableArray array];
82-
__NSArray_of(NSLayoutConstraint *) *returnedConstraints = [ALView autoCreateAndInstallConstraints:^{
82+
__NSArray_of(NSLayoutConstraint *) *returnedConstraints = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
8383
[createdConstraints addObjectsFromArray:[self.viewA autoPinEdgesToSuperviewEdges]];
8484
[createdConstraints addObject:[self.viewA_A autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.viewA_A.superview]];
8585
[createdConstraints addObject:[self.viewA_A autoAlignAxis:ALAxisVertical toSameAxisOfView:self.viewA_A.superview withOffset:10.0]];
@@ -104,14 +104,14 @@ - (void)testCreateAndInstallConstraintsNested
104104
__block __NSArray_of(NSLayoutConstraint *) *returnedConstraints1_1_1 = nil;
105105
__block __NSArray_of(NSLayoutConstraint *) *returnedConstraints1_2 = nil;
106106

107-
__NSArray_of(NSLayoutConstraint *) *returnedConstraints1 = [ALView autoCreateAndInstallConstraints:^{
107+
__NSArray_of(NSLayoutConstraint *) *returnedConstraints1 = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
108108
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeTop];
109109

110-
returnedConstraints1_1 = [ALView autoCreateAndInstallConstraints:^{
110+
returnedConstraints1_1 = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
111111
[self.viewB autoSetDimension:ALDimensionWidth toSize:100.0];
112112
[self.viewC autoSetDimension:ALDimensionHeight toSize:100.0];
113113

114-
returnedConstraints1_1_1 = [ALView autoCreateAndInstallConstraints:^{
114+
returnedConstraints1_1_1 = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
115115
[self.viewD autoConstrainAttribute:ALAttributeHeight toAttribute:ALAttributeWidth ofView:self.viewC withMultiplier:2.0];
116116
}];
117117
XCTAssertEqual(returnedConstraints1_1_1.count, 1);
@@ -125,7 +125,7 @@ - (void)testCreateAndInstallConstraintsNested
125125

126126
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeLeading];
127127

128-
returnedConstraints1_2 = [ALView autoCreateAndInstallConstraints:^{
128+
returnedConstraints1_2 = [NSLayoutConstraint autoCreateAndInstallConstraints:^{
129129
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeBottom];
130130
[self.viewA autoAlignAxisToSuperviewAxis:ALAxisVertical];
131131
}];
@@ -150,7 +150,7 @@ - (void)testCreateAndInstallConstraintsNested
150150
- (void)testCreateConstraintsWithoutInstalling
151151
{
152152
__NSMutableArray_of(NSLayoutConstraint *) *createdConstraints = [NSMutableArray array];
153-
__NSArray_of(NSLayoutConstraint *) *returnedConstraints = [ALView autoCreateConstraintsWithoutInstalling:^{
153+
__NSArray_of(NSLayoutConstraint *) *returnedConstraints = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
154154
[createdConstraints addObjectsFromArray:[self.viewA autoPinEdgesToSuperviewEdgesWithInsets:ALEdgeInsetsMake(10.0, 10.0, 10.0, 10.0) excludingEdge:ALEdgeBottom]];
155155
[createdConstraints addObject:[self.viewA_A autoAlignAxis:ALAxisVertical toSameAxisOfView:self.viewA_A.superview]];
156156
[createdConstraints addObject:[self.viewA_A autoAlignAxis:ALAxisBaseline toSameAxisOfView:self.viewA_A.superview withOffset:-10.0]];
@@ -175,14 +175,14 @@ - (void)testCreateConstraintsWithoutInstallingNested
175175
__block __NSArray_of(NSLayoutConstraint *) *returnedConstraints1_1_1 = nil;
176176
__block __NSArray_of(NSLayoutConstraint *) *returnedConstraints1_2 = nil;
177177

178-
__NSArray_of(NSLayoutConstraint *) *returnedConstraints1 = [ALView autoCreateConstraintsWithoutInstalling:^{
178+
__NSArray_of(NSLayoutConstraint *) *returnedConstraints1 = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
179179
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeTop];
180180

181-
returnedConstraints1_1 = [ALView autoCreateConstraintsWithoutInstalling:^{
181+
returnedConstraints1_1 = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
182182
[self.viewB autoSetDimension:ALDimensionWidth toSize:100.0];
183183
[self.viewC autoSetDimension:ALDimensionHeight toSize:100.0];
184184

185-
returnedConstraints1_1_1 = [ALView autoCreateConstraintsWithoutInstalling:^{
185+
returnedConstraints1_1_1 = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
186186
[self.viewD autoConstrainAttribute:ALAttributeHeight toAttribute:ALAttributeWidth ofView:self.viewC withMultiplier:2.0];
187187
}];
188188
XCTAssertEqual(returnedConstraints1_1_1.count, 1);
@@ -196,7 +196,7 @@ - (void)testCreateConstraintsWithoutInstallingNested
196196

197197
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeLeading];
198198

199-
returnedConstraints1_2 = [ALView autoCreateConstraintsWithoutInstalling:^{
199+
returnedConstraints1_2 = [NSLayoutConstraint autoCreateConstraintsWithoutInstalling:^{
200200
[self.viewA autoPinEdgeToSuperviewEdge:ALEdgeBottom];
201201
[self.viewA autoAlignAxisToSuperviewAxis:ALAxisVertical];
202202
}];

0 commit comments

Comments
 (0)