Maybe I'm stupid but I spent the whole afternoon trying to figure out this one. I'm an Objective C novice, but have plenty experience in other languages.
I have two NSCollectionView
- *eventsView
and *projectsView
inside a menu. Each with its own itemPrototype
which are two subclasses of NSCollectionViewItem
both with their own .xib files.
The problem is that it's always the first .xib file that loads - for both NSCollectionViewItem
. So projectsView
doesn't load its own .xib but it loads the eventsView
one. The funny thing is if I delete that .xib, both load the second .xib which no one loaded before.
I've run out of keywords to search for on Google, so here I am.
The code (though I don't know it matters) is:
NSMenuItem *events = [[NSMenuItem alloc] init];
self.eventsView = [[NSCollectionView alloc] initWithFrame:NSZeroRect];
HeadquartersEventsViewItem *eventsPrototype = [[HeadquartersEventsViewItem alloc] init];
[self.eventsView setItemPrototype:eventsPrototype];
[events setView:self.eventsView];
[self.menu addItem:events];
[self fetchEvents];
[self.menu addItem:[NSMenuItem separatorItem]];
NSMenuItem *projects = [[NSMenuItem alloc] init];
self.projectsView = [[NSCollectionView alloc] initWithFrame:NSZeroRect];
HeadquartersProjectsViewItem *projectsPrototype = [[HeadquartersProjectsViewItem alloc] init];
[self.projectsView setItemPrototype:projectsPrototype];
[projects setView:self.projectsView];
[self.menu addItem:projects];
[self fetchProjects];
Where is the catch? Why does Xcode not differentiate between those 2 .xibs?