After some research I gave up try adding a collection view inside the tableview.
Insted I added my verses manually in the subclass of the NSTableCellView
-(void) setObjectValue:(id)objectValue {
if (objectValue != nil)
{
[super setObjectValue:objectValue];
SongsInMedleys *Sim = objectValue;
Songs *song = Sim.withSongs;
scrollView *scrollview = [[scrollView alloc] initWithFrame:NSMakeRect(10,5,[self frame].size.width-30,145)];
int addverses = 0;
for (VersesInSongs *verse in song.withVerses)
{
if ([verse.lyric length] > 0) {
addverses += 1;
}
}
NSView *view = [[NSView alloc] initWithFrame:NSMakeRect(5, 10, ((addverses * (169+5))+5), 140)];
int x = 5;
NSSet *Verses = song.withVerses;
NSSortDescriptor *sortVerses = [[NSSortDescriptor alloc] initWithKey:@"number" ascending:YES];
NSArray *sortedVerses = [Verses sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortVerses]];
for (VersesInSongs *verse in sortedVerses)
{
if ([verse.lyric length] > 0) {
verseBox *box = [[verseBox alloc] initWithFrame:NSMakeRect(x, 10, 169, 130)];
[box setSong:song];
[box setVerse:verse];
[view addSubview:box];
x = x + 169+5;
}
}
[scrollview setDocumentView:view];
[self addSubview:scrollview];
}
}