Difficulty with medialibaryloader sample for swift 4

Has anyone successfully reproduced the Apple MediaLibraryLoader in Swift 4 ?


https://developer.apple.com/library/content/samplecode/MediaLibraryLoader


I find that if I download the project, it builds and runs just fine (minor issues with 4 vs 3.2).


However, when I try to reproduce the sample by hand from scratch, it keeps crashing with


[NSIndexSet objectAtIndex:]: unrecognized selector sent to instance 0x60000123fae0


after the media items have loaded, but before they are displayed.


I have replaced my handwritten code with the downloaded code sample, but the problem persists.....


Now I have tried going the through the xcode project settings and storyboard item, by item, to match what I a doing with what is present in the downloaded version to no sucess. With the project there is such a vast number of settings it is virtually impossible to be sure.


Is there a "diff" for project settings that anyone knows of ?


The complaint is happening after all the main code has completed. It finds all the media, builds content and adds all the items to the collectionView.


It *appears* to be failing when the underlying framework code is building the view. Superficially it is easy to see that NSIndexSet does not have the objectAtIndex method (duh), that is an NSArray method. So *something* is causing an NSArray to be treated as a NSIndexSet.


As the downloaded code builds and runs I am clearly missing something, but what ?


Any help would be appreciated.


Alan.

Accepted Reply

"My bad" as the grammatically challenged would say.......


😟 A fined grained item for item check of the storyboard revealled that I had bound the CollectionView/Content to the ArrayController.SelectionIndexes ..... when surprise, surprise, I should have bound the CollectionView/SelectionIndexes to the ArrayController.SelectionIndexes.....


sigh....


Alan.

Replies

"My bad" as the grammatically challenged would say.......


😟 A fined grained item for item check of the storyboard revealled that I had bound the CollectionView/Content to the ArrayController.SelectionIndexes ..... when surprise, surprise, I should have bound the CollectionView/SelectionIndexes to the ArrayController.SelectionIndexes.....


sigh....


Alan.