Generate UIView based on response from JSON

Does Swift support the ability to generate UIViews based on an amount specified in a JSON response?


Essentially, I’d like to present some UIViews on a VC but not every response will have the same amount of UIViews.


For example, if I have dataset which returns:


     Red      Green


It would generate two UIViews (one for red, one for green). I guess it would need to count (I’m happy to add another field to the API, e.g. ‘Views’) and look something like:


if jsonVar?.numberOfViews == "4" {


I hope that makes sense, I’m just trying to avoid displaying it all in a tableview as I’d like to style it better than what a tableview can offer.

Powered by WPeMatico


You may also like...

Comments are closed.