Wednesday, October 28, 2026
HomeiOS Developmentios - Having situation with dynamically add objects to collectionview

ios – Having situation with dynamically add objects to collectionview

[ad_1]

I’m fetching some information from the server, which is restricted to exhibiting 5 objects. At first, it masses 5 comparable so-called customers and reveals.

    func loadData(area: String?, class: Class?, depend: Int = 5) {
        let loadUserOp = UsersOperation(for: area, class: class, depend: depend)
        
        let successOp = DispatchOperation(situation: loadUserOp) {
            self.customers = loadUserOp.customers
            let objects = self.customers.map { CollectionViewItem(object: $0, cellID: "Cell") }
            self.collectionView.addItems(objects)
        }
        .
        .
        .
        // remainder of operations
}

As much as 5 customers must be proven. If it’s not 5, the remaining customers must be loaded with out the class filter (e.g. 4+1, 3+2, 2+3, 1+4, 0+5).

Now, must examine first if the loadUserOp.customers.depend is < 5 name loadData operate once more and now this time with out class. So my query is how can I calculate the remainder of the depend after which add to objects utilizing self.collectionView.addItems(objects)

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments