EDIT: I'm not going to do this, I now realize how dangerous this can be. But, the question stays for purely academic purposes.
I'm trying to implement a category on NSCollectionView that will let me access the private variable _displayedItems. I need to be able to access it in my subclass. So, I've created the following category:
@interface NSCollectionView (displayedItems)
- (NSMutableArray *)displayedItems;
@end
@implementation NSCollectionView (displayedItems)
- (NSMutableArray *)displayedItems
{
return _displayedItems;
}
@end
...which seems like it should work perfectly. However, when I try to compile this, the linker gives me the following error:
Undefined symbols:
"_OBJC_IVAR_$_NSCollectionView._displayedItems", referenced from:
-[NSCollectionView(displayedItems) displayedItems] in NSCollectionView+displayedItems.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I know for a fact that _displayedItems exists in NSCollectionView, I've looked at the interface and also printed it's contents using gdb. Does anyone know of a way to fix this?
Thanks in advance!
Billy