From f1ebe246b81b4868348ec44de83b5d1d80d822e6 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 7 Aug 2017 11:04:31 -0700 Subject: [PATCH] Rename -[ASCellNode viewModel] to -[ASCellNode nodeViewModel] to avoid collisions (#499) * Rename -[ASCellNode viewModel] -> -[ASCellNode nodeViewModel] to avoid breaking existing code * Update test * Update the changelog --- CHANGELOG.md | 1 + Source/ASCellNode.h | 2 +- Source/ASCellNode.mm | 2 +- Source/Details/ASCollectionElement.mm | 2 +- Tests/ASCollectionModernDataSourceTests.m | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9f2f007c..94b88bd11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Add -[ASDisplayNode detailedLayoutDescription] property to aid debugging. [Adlai Holler](https://github.com/Adlai-Holler) [#476](https://github.com/TextureGroup/Texture/pull/476) - Fix an issue that causes calculatedLayoutDidChange being called needlessly. [Huy Nguyen](https://github.com/nguyenhuy) [#490](https://github.com/TextureGroup/Texture/pull/490) - Negate iOS 11 automatic estimated table row heights. [Christian Selig](https://github.com/christianselig) [#485](https://github.com/TextureGroup/Texture/pull/485) +- Rename ASCellNode.viewModel to ASCellNode.nodeViewModel to reduce collisions with subclass properties implemented by clients. [Adlai Holler](https://github.com/Adlai-Holler) [#499](https://github.com/TextureGroup/Texture/pull/499) ##2.3.5 - Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler) diff --git a/Source/ASCellNode.h b/Source/ASCellNode.h index ca9dda629..bcd5b9ccf 100644 --- a/Source/ASCellNode.h +++ b/Source/ASCellNode.h @@ -123,7 +123,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { * * This property may be set off the main thread, but this method will never be invoked concurrently on the */ -@property (atomic, nullable) id viewModel; +@property (atomic, nullable) id nodeViewModel; /** * Asks the node whether it can be updated to the given view model. diff --git a/Source/ASCellNode.mm b/Source/ASCellNode.mm index e3d2d25e5..6ff4b7d83 100644 --- a/Source/ASCellNode.mm +++ b/Source/ASCellNode.mm @@ -172,7 +172,7 @@ - (void)__setHighlightedFromUIKit:(BOOL)highlighted; - (BOOL)canUpdateToViewModel:(id)viewModel { - return [self.viewModel class] == [viewModel class]; + return [self.nodeViewModel class] == [viewModel class]; } - (NSIndexPath *)indexPath diff --git a/Source/Details/ASCollectionElement.mm b/Source/Details/ASCollectionElement.mm index 955cc5f11..3c16011da 100644 --- a/Source/Details/ASCollectionElement.mm +++ b/Source/Details/ASCollectionElement.mm @@ -64,7 +64,7 @@ - (ASCellNode *)node node.owningNode = _owningNode; node.collectionElement = self; ASTraitCollectionPropagateDown(node, _traitCollection); - node.viewModel = _viewModel; + node.nodeViewModel = _viewModel; _node = node; } return _node; diff --git a/Tests/ASCollectionModernDataSourceTests.m b/Tests/ASCollectionModernDataSourceTests.m index ec97e8c64..5fd096f19 100644 --- a/Tests/ASCollectionModernDataSourceTests.m +++ b/Tests/ASCollectionModernDataSourceTests.m @@ -254,7 +254,7 @@ - (void)assertCollectionNodeContent id viewModel = viewModels[indexPath.item]; XCTAssertEqualObjects(viewModel, [collectionNode viewModelForItemAtIndexPath:indexPath]); ASCellNode *node = [collectionNode nodeForItemAtIndexPath:indexPath]; - XCTAssertEqualObjects(node.viewModel, viewModel); + XCTAssertEqualObjects(node.nodeViewModel, viewModel); } } }