How to create NSCollectionView programmatically from scratch?

前端 未结 3 1023
傲寒
傲寒 2020-12-13 02:32

NSCollectionView remains one of the most mysterious parts of the Cocoa API that I\'ve ever seen. Documentation is poor and there are many moving parts, many of

3条回答
  •  孤街浪徒
    2020-12-13 02:52

    To answer brigadir's question on how to bind to a mutable array.

    zero'th - make titles an NSMutableArray

    first - bind the array to your items

    [cv bind:NSContentBinding 
        toObject:self 
        withKeyPath:@"titles" 
        options:NULL];
    

    Second - when altering titles, make sure to modify the proxy.

    e.g.

    NSMutableArray *kvcTitles = [self mutableArrayValueForKey:@"titles"];
    [kvcTitles removeLastObject];
    

提交回复
热议问题