Function: List and select contentApp categories

Note that in SDK Multi Mode only the categories from your contentDock user account are used. If individual categories are selected, only those will be made available when loading private and public contentApps that have also set one of the selected categories.

Example list and select categories
import UIKit
import CDockFramework

class VCCustomCategories: UIViewController {
    @IBOutlet weak var collectionView: UICollectionView!

    var arrDatasource: [CategoryModel] = []
    var arrSelectedCategoriesIDs:Set<Int> = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Your individual function
        // ...

        /*
        Load all categories created in your contentDock user account
        */
        CDockSDK.getCategories {[weak self] arr in
            if let arrCategories = arr as? [CategoryModel] {
                guard let s = self else { return }
                s.arrDatasource = arrCategories
                // Your individual function
                // ...
            }
        }
    }

    private func saveSelectedCategoriest() {
        // Your individual function
        // ...
        let arr = arrSelectedCategoriesIDs.map { i -> NSNumber in
            return NSNumber(value: i)
        }

        /*
        Save all selected categories in the SDK. If the categories are set in the SDK, they are taken into account when loading the private (CDockSDK.getPrivateProjects) and public (CDockSDK.getPublicProjects) projects. 
        */
        CDockSDK.setArrSelectedCategories(arr)
    }
}

More information


Feedback or Questions

We are always happy to help you with questions about the code or other questions.

Was this page helpful? Yes No

Topics on this page