Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming ivar context can conflict with subclasses #1399

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority;
@interface ASDisplayNode : NSObject <ASLocking> {
@public
/**
* The _context ivar is unused by Texture, but provided to enable advanced clients to make powerful extensions to base class functionality.
* For example, _context can be used to implement category methods on ASDisplayNode that add functionality to all node subclass types.
* The _displayNodeContext ivar is unused by Texture, but provided to enable advanced clients to make powerful extensions to base class functionality.
* For example, _displayNodeContext can be used to implement category methods on ASDisplayNode that add functionality to all node subclass types.
* Code demonstrating this technique can be found in the CatDealsCollectionView example.
*/
void *_context;
void *_displayNodeContext;
}

/** @name Initializing a node object */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
NSString *loggingID = nil;
};

// Convenience to cast _context into our struct reference.
// Convenience to cast _displayNodeContext into our struct reference.
NS_INLINE CatDealsNodeContext &GetNodeContext(ASDisplayNode *node) {
return *static_cast<CatDealsNodeContext *>(node->_context);
return *static_cast<CatDealsNodeContext *>(node->_displayNodeContext);
}

@implementation ASDisplayNode (CatDeals)

- (void)baseDidInit
{
_context = new CatDealsNodeContext;
_displayNodeContext = new CatDealsNodeContext;
}

- (void)baseWillDealloc
Expand Down