diff --git a/AsyncDisplayKit/Layout/ASDimension.mm b/AsyncDisplayKit/Layout/ASDimension.mm index 53b03b7670..cf58e1c517 100644 --- a/AsyncDisplayKit/Layout/ASDimension.mm +++ b/AsyncDisplayKit/Layout/ASDimension.mm @@ -18,16 +18,21 @@ ASRelativeDimension const ASRelativeDimensionUnconstrained = {}; ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type, CGFloat value) { if (type == ASRelativeDimensionTypePoints) { ASDisplayNodeCAssertPositiveReal(@"Points", value); } + if (type == ASRelativeDimensionTypePercent) { + ASDisplayNodeCAssert( 0 <= value && value <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", value); + } ASRelativeDimension dimension; dimension.type = type; dimension.value = value; return dimension; } ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points) { + ASDisplayNodeCAssertPositiveReal(@"Points", points); return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points); } ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent) { + ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent); return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent); }