Optimizing for the 500 widgets and updating it faster in iOS

I am creating 500 textfield widgets and then updating them and all their 40 properties at once. I require to update all 500 widgets with their properties at once as it is a usecase in our app, so pooling and showing only those that will be on screen won't really help in this case.

I have found that for updating all these 500 textfield widgets with their 40 properties, the time taken is 80 to 100 milliseconds.

However, if I update the non-string properties like .text, then it comes down to half which is 40 to 50 milliseconds.

Wanted to know if there was a far more quicker or optimized way to do this?

The following snippet of code shows what I am doing:

@objc private func handleImmediateMode() {
        let startTime = CFAbsoluteTimeGetCurrent()
        for (index, textField) in retainedInputFields.enumerated() {
            updateAllProperties(for: textField, index: index)
        }
        let endTime = CFAbsoluteTimeGetCurrent()
        print("Immediate Mode -- (500 fields, 40 props): \( (endTime - startTime) * 1000) ms")
    }

In the above code, I have already created the 500 textfield widget, and then in updateAllProperties () function I am passing the textfield widget to it and then updating the 40 properties that the widget has.

Particularily, the following properties:

  1. textField.placeholder = "Input Field (index)"
  2. UILabel().text

Seem to be adding the extra 40 - 50 milliseconds.

Optimizing for the 500 widgets and updating it faster in iOS
 
 
Q