/***************************************************************************** * GenreModel.swift * * Copyright © 2018 VLC authors and VideoLAN * Copyright © 2018 Videolabs * * Authors: Soomin Lee * * Refer to the COPYING file of the official project for license. *****************************************************************************/ class GenreModel: MLBaseModel { typealias MLType = VLCMLGenre var updateView: (() -> Void)? var files = [VLCMLGenre]() var medialibrary: VLCMediaLibraryManager var indicatorName: String = NSLocalizedString("GENRE", comment: "") required init(medialibrary: VLCMediaLibraryManager) { self.medialibrary = medialibrary medialibrary.addObserver(self) // created too late so missed the callback asking if he has anything files = medialibrary.genre() } func isIncluded(_ item: VLCMLGenre) { } func append(_ item: VLCMLGenre) { // need to check more for duplicate and stuff files.append(item) } } extension GenreModel: MediaLibraryObserver { func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddGenre genre: [VLCMLGenre]) { genre.forEach({ append($0) }) updateView?() } }